Cov txheej txheem:

Khaws Cov Ntaub Ntawv Nrog ESP8266/ESP32: 7 Cov Kauj Ruam
Khaws Cov Ntaub Ntawv Nrog ESP8266/ESP32: 7 Cov Kauj Ruam

Video: Khaws Cov Ntaub Ntawv Nrog ESP8266/ESP32: 7 Cov Kauj Ruam

Video: Khaws Cov Ntaub Ntawv Nrog ESP8266/ESP32: 7 Cov Kauj Ruam
Video: Tseem Ev Lub Kawm - Koos Loos 2024, Kaum ib hlis
Anonim
Khaws Cov Ntaub Ntawv Nrog ESP8266/ESP32
Khaws Cov Ntaub Ntawv Nrog ESP8266/ESP32
Khaws Cov Ntaub Ntawv Nrog ESP8266/ESP32
Khaws Cov Ntaub Ntawv Nrog ESP8266/ESP32

Koj puas tau xav tau txais cov ntaub ntawv rau koj cov phiaj xwm Arduino, tab sis tsis muaj pej xeem API rau nws? Los yog qee zaum zoo li Instagram API qhov txheej txheem teeb tsa rau qhov tsis yooj yim heev?

Hauv Cov Lus Qhia no peb yuav saib 2 qhov kev xaiv sib txawv rau kev khawb cov ntaub ntawv los ntawm lub vev xaib rau koj li ESP8266 lossis ESP32 cov haujlwm.

Kauj Ruam 1: Txheeb Tawm Daim Video

Image
Image

Kuv tau ua cov vis dis aus uas npog tib yam li cov lus qhia no, yog li yog koj xav tau, thov txheeb xyuas nws!

Kauj ruam 2: Ua ntej Peb Pib

Ua ntej Peb Pib
Ua ntej Peb Pib
Ua ntej Peb Pib
Ua ntej Peb Pib

Tsuas yog lub taub hau hais tias cov ntaub ntawv kuv yuav tham txog kev khawb yog pej xeem ntsib cov ntaub ntawv thiab tsis xav tau kev txheeb xyuas qhov tseeb. Yog li hais piv txwv, kuv tus lej YouTube tus neeg siv pes tsawg tsuas yog muaj rau kuv hauv tus tsim studio, yog li lub cuab yeej yuav tsum tau thov kom lees paub qhov tseeb raws li kuv tau thauj nws. Cov hom kev thov no yuav tsis muaj qhov txwv rau daim vis dis aus no. Kev sim nrawm los tshuaj xyuas nws puas yuav tsum yog txhawm rau rub cov nplooj ntawv hauv lub qhov rai tsis qhia npe vim tias yuav tsis cia koj nkag mus rau txhua qhov chaw.

Txog cov txheej txheem uas tau hais hauv Phau Ntawv Qhia no peb yuav tau siv qee yam ntawm cov cuab yeej tsim tawm uas muaj nyob hauv cov browser. Kuv yuav qhia lawv nrog Firefox, tab sis kuv paub qee yam Chrome muaj cov cuab yeej zoo sib xws thiab kuv paub tseeb tias lwm cov browser muaj lawv ib yam.

Kauj Ruam 3: Tsis yog APIs rau pej xeem (Spoiler: Cov Lus Qhia Muaj Ib!)

Tsis yog APIs rau pej xeem (Spoiler: Cov Lus Qhia Muaj Ib!)
Tsis yog APIs rau pej xeem (Spoiler: Cov Lus Qhia Muaj Ib!)
Tsis yog APIs rau pej xeem (Spoiler: Cov Lus Qhia Muaj Ib!)
Tsis yog APIs rau pej xeem (Spoiler: Cov Lus Qhia Muaj Ib!)
Tsis yog APIs rau pej xeem (Spoiler: Cov Lus Qhia Muaj Ib!)
Tsis yog APIs rau pej xeem (Spoiler: Cov Lus Qhia Muaj Ib!)

Thawj txoj hauv kev peb yuav saib yog siv API tsis yog pej xeem. Qhov no yuav tsis muaj ib txwm muaj, tab sis yog nws yog qhov no yog qhov tseeb uas koj yuav tsum tau siv. Qhov kuv tab tom hu rau "tsis yog pej xeem API" yog qhov uas ib lub vev xaib siv API tsis tau tshaj tawm ntawm lawv lub vev xaib tom qab qhov xwm txheej mus nqa cov ntaub ntawv peb tab tom nrhiav kom tau.

Muaj qee qhov laj thawj yog vim li cas qhov no yuav yog qhov kev xaiv zoo dua los siv.

  1. Qhov txiaj ntsig loj tshaj yog qhov nws tsis zoo li yuav hloov pauv ntau li lub vev xaib, yog tias koj khawb cov ntaub ntawv ncaj qha los ntawm lub vev xaib HTML, txhua lub sijhawm lawv hloov pauv rau lub xaib, koj qhov kev cais tawm yuav tawg.
  2. Nws ib txwm muaj cov ntaub ntawv zoo dua. Thaum koj tab tom khawb lub vev xaib koj tau rub tawm tag nrho nplooj ntawv HTML txhawm rau rho tawm cov ntaub ntawv los ntawm nws, APIs yuav tsuas yog rov qab cov ntaub ntawv cov ntsiab lus yog li feem ntau yuav thov ntau dua.
  3. Feem ntau nws yooj yim dua rau kev cais tawm. Feem ntau APIs xa cov ntaub ntawv hauv JSON hom ntawv uas yooj yim rau kev cais, qhov no tshwj xeeb tshaj yog yog tias koj tau rho tawm ntau daim ntawm cov ntaub ntawv.

Peb yuav tsum xub nrhiav seb lub vev xaib siv teeb tsa zoo li no. Qhov teeb meem loj tshaj yog tias lub xaib hloov kho tus nqi hauv lub sijhawm zoo li nws ua ntawm Kickstarter, tab sis txawm tias nws tsis muaj tseem vam tias nws yuav siv qhov teeb tsa no. Cov lus qhia siv API tsis yog pej xeem rau nqa qee cov ntaub ntawv rau lawv lub xaib txawm tias nws tsis rov ua dua tshiab hauv lub sijhawm.

Txhawm rau txheeb xyuas yog tias lub xaib siv qhov teeb tsa no, nkag mus rau tus tsim tawm ntawm koj tus browser, Kuv pom txoj hauv kev yooj yim tshaj plaws ntawm qhov no yog nyem rau ntawm nplooj ntawv thiab xaiv "tshuaj xyuas ntu".

Tom qab ntawd koj yuav xav mus rau lub network tab, qhov no yuav tso saib qhov kev thov lub vev xaib ua rau hauv keeb kwm yav dhau, nco ntsoov tias koj yuav xav tau rov qhib nplooj ntawv tom qab qhib lub tab no vim tias nws tsuas yog qhia kev thov ua txij tam sim no mus.

Koj ib txwm xav nrhiav cov uas muaj hom "json". Muaj peev xwm thov tau ntau ntawm no, yog li nws tuaj yeem pab txheeb los ntawm hom. Koj tuaj yeem pom nws pom tseeb ntawm nplooj ntawv phiaj xwm phiaj xwm uas nws tau siv qhov teeb tsa no zoo li koj tuaj yeem pom qhov kev thov tas li ua rau "stats.json" qhov kawg. Ntawm Tus kws qhia ntawv nplooj ntawv (piv txwv li kuv yog "https://www.instructables.com/member/witnessmenow/"), lawv tsis ua qhov kev thov tas li, tab sis koj tuaj yeem pom qhov zais ntawm lwm tus neeg thov rau "showAuthorStats" qhov kawg.

Txhawm rau paub cov ntaub ntawv ntau ntxiv txog qhov kev thov no, koj tuaj yeem nyem rau nws. Koj yuav tsum muaj peev xwm tau txais txhua cov ntaub ntawv koj xav tau los ntawm no txhawm rau rov ua dua qhov kev thov. Tab sis ua ntej koj ua qhov uas koj xav tau ua ntej ob zaug xyuas tias nws muaj cov ntaub ntawv koj xav tau. Nyem, ntawm kab lus teb thiab pom tias cov ntaub ntawv nyob ntawd.

Yog tias nws muaj cov ntaub ntawv koj xav tau, koj tau teeb tsa tag nrho! Koj tuaj yeem siv tib txoj hauv kev tham hauv kuv cov vis dis aus dhau los txog kev txuas mus rau APIs. Cov ntawv luv ntawm qhov ntawd yog kom ntseeg tau tias qhov kev thov ua haujlwm raws li qhov xav tau ntawm cov cuab yeej zoo li Postman ua ntej thiab tom qab ntawd siv qhov piv txwv no los sim seb nws ua haujlwm ntawm koj lub cuab yeej.

Txog kev txheeb xyuas cov ntaub ntawv JSON Kuv xav kom siv ArudinoJSON hauv ntau qhov xwm txheej, yog tias qhov no yog qee yam koj xav tau qhia qhia, tsuas yog qhia rau kuv paub!

Kauj Ruam 4: Khaws Cov Ntaub Ntawv Ncaj Ncees

Scraping Cov Ntaub Ntawv Ncaj Ncees
Scraping Cov Ntaub Ntawv Ncaj Ncees
Scraping Cov Ntaub Ntawv Ncaj Ncees
Scraping Cov Ntaub Ntawv Ncaj Ncees
Scraping Cov Ntaub Ntawv Ncaj Ncees
Scraping Cov Ntaub Ntawv Ncaj Ncees

Tom ntej no peb yuav saib scraping cov ntaub ntawv ncaj qha los ntawm lub vev xaib, qhov no tau thov tag nrho lub vev xaib ntawm lub cuab yeej thiab txheeb xyuas cov ntaub ntawv peb xav tawm. Kuv twb tau hais txog qhov zoo ntawm API tsis yog pej xeem muaj dhau txoj kev no, tab sis qee zaum xav tau yuav tsum tau!

Ib yam uas tseem ceeb yuav tsum tau sau tseg ntawm no, yog tias koj tau paub txog kev txhim kho lub vev xaib koj yuav raug siv los tshuaj xyuas cov yam ntxwv kom paub cov ntaub ntawv hais txog ib qho tshwj xeeb thiab nws tau teeb tsa li cas. Qhov no yuav tsum zam rau txoj hauv kev no, vim tias nplooj ntawv web niaj hnub no feem ntau hloov pauv siv Javascript, uas yuav tsis tshwm sim ntawm koj lub cuab yeej. Tus lej HTML uas muaj nyob ntawm koj lub cuab yeej tsuas yog thawj lub vev xaib uas tau rub tawm. Ib qho piv txwv zoo ntawm qhov no yog TeamTrees nplooj ntawv, suav cov nyiaj pub dawb tam sim no pib ua 0 thiab tau nkag mus rau nplooj ntawv tom qab nrog cov duab no, tab sis tsis zoo li ob qhov piv txwv peb tau pom ua ntej, nws tsis thauj cov ntaub ntawv hauv keeb kwm yav dhau, yog li cov ntaub ntawv raug yuav tsum yog lwm qhov.

Txhawm rau saib thawj lub vev xaib tus lej koj tuaj yeem nyem rau ntawm nplooj ntawv thiab xaiv "Saib Source". Tom qab ntawd koj xav tshawb nrhiav cov ntaub ntawv tshwj xeeb uas koj xav tau, yog li hauv TeamTrees piv txwv thaum peb tshawb nrhiav cov nyiaj pub dawb tam sim no, peb tuaj yeem pom qhov suav tiag yog khaws cia hauv cov ntaub ntawv-suav cov cuab yeej ntawm cov khoom suav, qhov no yog qhov peb xav tau khawb cov ntaub ntawv los ntawm.

Koj yuav tsum nrhiav txoj hlua tshawb nrhiav uas coj koj mus rau koj cov ntaub ntawv, Nws yooj yim dua los xam qhov no ua ntej coding rau lub cuab yeej. Txog qhov piv txwv no, tshawb rau "cov ntaub ntawv suav" "coj kuv mus rau cov ntaub ntawv peb xav tau, uas zoo tshaj. Peb tsis tas yuav txhawj xeeb tias nws tseem sib phim hauv lwm qhov chaw hauv nplooj ntawv, vim tias nws yuav ntaus ib qho ua ntej tshaj plaws. Yog tias koj xav tau ntaus tus thib 3, koj tuaj yeem ua haujlwm nws kom tsis quav ntsej thawj 2 koj ntaus.

Yog tias peb saib ntawm TeamTrees piv txwv, zoo li ua ntej peb tau hla hla cov lus teb thiab tam sim no saib lub cev ntawm cov lus teb (uas yog lub vev xaib). Dab tsi rov qab los ntawm cov neeg siv khoom yog cov kwj ntawm cov ntaub ntawv. Peb tsis quav ntsej txog dab tsi txog rau peb cov lus nug tshawb nrhiav, yog li peb ua tus thov kev pab. Yog tias nws pom cov lus nug tshawb nrhiav nws yuav rov qab muaj tseeb thiab nws yuav txav cov kwj deg mus rau qhov kawg ntawm cov lus nug. Qhov txuas ntxiv uas muaj los ntawm cov kwj yuav yog cov ntaub ntawv peb tab tom nrhiav, tab sis qhov no peb tsis paub meej tias cov ntaub ntawv yuav nyob ntev npaum li cas, tab sis peb paub nws yog txhua yam ntaub ntawv ntawm peb qhov chaw tam sim no hauv kwj thiab tom ntej tom ntej hloov pauv. Peb tuaj yeem ua tiav qhov no los ntawm kev siv "client.readBytesUntil" uas ua raws li nws hais, nws nyeem cov bytes rau hauv qhov tsis txog thaum nws tsoo cov lus nug tshwj xeeb. Tsuas yog xyuas kom tsis txhob cuam tshuam koj tau nyeem rau hauv yog loj txaus los tuav tag nrho cov ntaub ntawv, Kuv xav tias peb nyob nraum zoo nyob ntawm no nrog 32!

Yog tias koj muaj tag nrho cov ntaub ntawv koj xav tau, tom qab ntawd koj tsis tas yuav nyeem cov ntaub ntawv ntxiv lawm. Kuv tsis tau kaw qhov kev sib txuas ntawm no vim tias nws tsis zoo li ua teeb meem ntawm ESP8266, nws zoo li ua rau muaj teeb meem nrog ESP32, yog li kuv ntxiv tus thov kev pab.stop (). Yuav kom ua ncaj ncees, Kuv tsis paub yog vim li cas kuv tso nws rau saum tus txheej txheem, Kuv xav tias nws yuav ua rau muaj kev nkag siab ntau dua los kaw nws thaum koj muaj cov ntaub ntawv koj xav tau.

Kauj Ruam 5: Khaws Cov Ntaub Ntawv Siv Tus Neeg Siv Khoom Sab Nraud:

Scraping Cov Ntaub Ntawv Siv Tus Neeg Siv Khoom Sab Nraud
Scraping Cov Ntaub Ntawv Siv Tus Neeg Siv Khoom Sab Nraud
Scraping Cov Ntaub Ntawv Siv Tus Neeg Siv Khoom Sab Nraud
Scraping Cov Ntaub Ntawv Siv Tus Neeg Siv Khoom Sab Nraud

Tsuas yog lwm lub ncauj lus los kov, muaj ntau yam cuab yeej zoo dua rau kev tshuaj xyuas ntawm lub khoos phis tawj ib puag ncig xws li NodeJS dua li ntawm lub micro tswj, yog li qee zaum nws yuav ua rau muaj txiaj ntsig los ua qhov kev pabcuam uas nqa cov ntaub ntawv los ntawm lub vev xaib thiab muab qhov yooj yim dua. qhov kawg rau koj ESP8266 lossis ESP32. Ib qho piv txwv ntawm qhov no yog scraping CrowdSupply nplooj ntawv kom tau txais kev suav nyob ntawm pes tsawg TinyPICO tau muag. Nws yuav muaj peev xwm ua tiav nws ncaj qha ntawm ESP8266 lossis ESP32, tab sis raws li nws tau txheeb xyuas ntau cov ntsiab lus sib txawv ntawm cov ntsiab lus ntawm ntau qhov sib txawv, yog li nws yuav nyuaj.

Kuv xaus qhov tsim NodeJS txoj haujlwm thiab txheeb xyuas cov ntaub ntawv siv lub tsev qiv ntawv hu ua cheerio thiab nws ua haujlwm tau zoo heev. Kuv tau tuav txoj haujlwm no ntawm huab neeg rau zaub mov kuv twb muaj lawm, tab sis koj tuaj yeem ua qhov haujlwm zoo li no ntawm tus pi yog tias koj tsis muaj qee yam zoo li kev teeb tsa.

Kauj Ruam 6: Kev Txwv Kev Siv

Kev Txwv Kev Siv
Kev Txwv Kev Siv

Ib yam uas tuaj yeem muaj feem cuam tshuam rau txhua txoj hauv kev no yog tsoo qhov chaw txwv kev siv. Hauv APIs tsis tu ncua nws ib txwm ua tau zoo sau tseg tias muaj pes tsawg qhov kev thov koj tuaj yeem ua rau ib feeb lossis ib hnub thiab koj tuaj yeem txwv koj cov phiaj xwm thov raws li qhov no. Thaum koj tab tom khawb, koj tsis paub tias cov kev txwv no yog li cas koj thiaj muaj kev pheej hmoo los tsoo lawv thiab muaj peev xwm raug thaiv. Kuv tsis tuaj yeem muab cov lus qhia tseeb txog kev txwv nws yog li koj nyob hauv lawv phau ntawv zoo, tab sis kuv xav tias txhua yam hauv qab txhua feeb yuav ntau dhau, tsis yog qee zaum zoo li kickstarter qhov twg lawv zoo li thov txhua ob peb feeb lawv tus kheej.

Kauj Ruam 7: Ua Tsaug Rau Kev Nyeem

Vam tias qhov vis dis aus no pab tau yog tias koj xav cais cov ntaub ntawv ncaj qha los ntawm lub vev xaib ntawm koj ESP8266 lossis ESP32. Koj puas muaj lwm cov lus nug ntawm lub ncauj lus uas kuv tsis tau npog? Thov qhia rau kuv paub hauv cov lus hauv qab no, lossis koom nrog kuv thiab ib pawg ntawm lwm tus tsim ntawm kuv li Discord server, qhov uas peb tuaj yeem tham txog cov ncauj lus no lossis lwm tus tsim muaj feem cuam tshuam nrog koj muaj, tib neeg yeej muaj txiaj ntsig zoo yog li nws yog qhov chaw zoo rau dai tawm

Kuv kuj tseem xav ua tsaug ntau rau kuv Github Sponsors uas pab txhawb qhov kuv ua, Kuv yeej txaus siab rau nws. Yog tias koj tsis paub, Github sib piv cov kev txhawb nqa rau thawj xyoo, yog li yog koj ua tus txhawb nqa lawv yuav phim nws 100% rau ob peb hlis tom ntej.

Ua tsaug rau kev nyeem ntawv!

Pom zoo: