Nov 07, 2021 07:43 AM
Hello
is it possible to import data from an HTML web page into Airtable
for example, i would like to retrieve the data “priceValue” in coinmarketcap.com/currencies/solana
i’m trying with DataFetcher but it seems not to work properly.
Is there another way to achieve ?
thanks for your answer
Nov 07, 2021 03:02 PM
Hi,
I had a similar task, but now it’s low prio among others, unfinished, so I can share my experience at that moment.
i used following method to get JSON-object from API, parse and output.
Nov 11, 2021 07:27 AM
Well i was able to perform the same with html
(skipped first lines to fetch…it works for different Name field values implemented in google search "site:somesite.com My Search Sentence, and script run by button)
i know there is some better way to parse HTML and i’ve “invented a wheel”, but that’s just an example it can be done quite easy. Just output(inspect) a fetch result and think how to locate your value.
...
let response = await remoteFetchAsync(word);
const pageSummary = await response.text();
let location=pageSummary.indexOf('property_name')-80;
if (location<0) throw new Error(word+' Not Found');
let pos1=pageSummary.indexOf('https:',location);
let pos2=pageSummary.indexOf('&sa',pos1);
let address=pageSummary.slice(pos1,pos2).trim();
//my output is link with "wrong" symbols and i need to correct them.
//Maybe that part not interesting for your case
//looping because replace only works with first match, so
function rplc(text){return text.replace('%3F','?').replace('%3D','=').
replace('%26','&').replace('%2B','+')};
let temp_adr=rplc(address);
while (temp_adr!=address) {address=temp_adr;temp_adr=rplc(address) }
await rootTable.updateRecordAsync(record.id,{ 'URL_on_BRD' : address } );
output.text(pos1+' - '+pos2);
output.inspect(address);