Is there a way to get the data from an editorjs block?
I can get the Block itself via e.g. editor.blocks.getBlocksByIndex(0) but I can't find any property that lets me get the type or data like the heading tools level.
Related
I'm following this instruction to embed the Trustpilot on my website. It will render a tag that contains the data.
I would like to check when the data is empty like this:
I found that the Trustpilot will create an object like this window.Trustpilot.Modules.WidgetManagement but still don't know how to detect that the data is empty or not.
I'm trying to scrape data from this url https://drive.getbigger.io/#/stores, however I didn't find the Xpath of the text I want to export, which are the producer's offer.
Firstly I try the importxml function in Google sheet:
=IMPORTXML(A1;"/html/body/flt-ruler-host/div[23]/p")
and it gave me N/A error "the imported content is empty"
so I try to scrape this website with add-ons and Parsehub, and it gave me every time a .csv file where i can't find the data I want to export.
Also I can't find the right Xpath for the data I would like to scrape, when I use the inspection tool, the data isn't in the <body> part.
However the Xpath I use in my importXML function is some code I find in the <body> part and which is close of the text I'd like to extract (the producer's offer).
It seems that the Xpath I am looking for is linked in the <head> part with some JavaScript code, also when I hover the page with the selection tool in order to scrape the data it select the whole page, maybe because there is a "scroll <div>".
So I wonder if the website use some kind of protection against scraping or other.
Please guys tell me if :
I could find the right Xpath in order to scrape with the importXML function?
Should I extract the data with a python script?
if the website block my attempts, how could I do this?
You won't be able to scrape anything with IMPORTXML formula since the website uses dynamic rendering (javascript).
So yes, Python+Selenium (or other combinations) could do the job. The website won't block you if you follow some rules (switch user-agent, add pauses between requests).
You would probably need these XPath :
Product description :
//p[1][string-length(text())>5][parent::flt-dom-canvas]
Product price :
//p[3][contains(text(),"€") and not (contains(text(),","))][parent::flt-dom-canvas]
However, I think the most elegant way to get the data is probably to use the API the website relies upon. With GoogleSheets and a custom ImportJSON script, you can obtain something like this (result for "fromage" as query) :
It won't work out of the box, you'll have to modify some parts of the script since it won't load a JSON (called with POST) which needs headers in the request. In a nutshell, you need to construct the payload part, add headers to the request ("Bearer XXXXX"), and add a parameter to a function to retrieve the results.
All this depends on your objective and your expected output.
EDIT : For references (constructing the payload, adding parameters) you can read :
https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#fetchurl,-params
Look also the networktab of your browser developper tools in order to find : the url of the API and the correct parameters to send.
I'm trying to make my own DB with data pulled from a Javascript Variable located on this URL (https://www.numberfire.com/nba/fantasy/fantasy-basketball-projections/). Since the data is only made available in the variable (NF_DATA), I'm not able to easily query as I would an API.
I'm able to pull the data as I would any JSON object using the Chrome Developer Console as such:
I would like to be able to pull data with a Python script in the same way as I was doing in the Chrome Developer Console. (For instance, identifying the exact data by writing 'NF_DATA['daily_projections']['1'][...]' in the script, so I can do the manipulation directly in the script, not in Chrome Devtools). Any recommendations on how I do this? I have tried using BeautifulSoup in Python, but was having trouble grabbing the data without making the complete output into a string (would this even be a good way to think about it??)
I need to get the name of a company into a Google spreadsheet.
The GOOGLEFINANCE function doesn't include the name of the company in its attributes, so I'm trying to create a custom function for that.
So, for IBM, for example, I can fetch the URL:
https://www.google.com/finance?q=ibm
And using Javascript, I'm trying to get the text of the name using:
document.getElementsByClassName('appbar-snippet-primary')[0].getElementsByTagName("span")[0].innerHTML
Which is returning:
undefined
If you are trying to do that inside apps scripts it wont be possible, the version of javascript in apps script does not contain the document object, therefore you won't be able to do it like that.
If you return that response to the client(where the javascript contains the document object) in order to look for the item in that way, you should have first add the information to that object.
a possible solution would be to treat the result of the urlfetch as string and then look for the information you require.
I'm trying to develop a custom xtype that extends the tags xtype defined in
/libs/cq/tagging/widgets/source/widgets/TagInputField.js
I have the function defined in another file
CQ.tagging.customTagInputField = CQ.Ext.extend(CQ.TagInputField, { /*A whole bunch of code here */ });
CQ.Ext.reg("customtags", CQ.tagging.customTagInputField);
Yet every time I try to boot up a page containing my custom widget I get an error in my console saying
TypeError: sp is undefined
spp = sp.prototype;
According to the all wise and knowing Google. This kind of error usually means I'm trying to extend something that doesn't exist. However changing
CQ.Ext.extend(CQ.TagInputField,
to something a bit more specific like
CQ.Ext.extend(CQ.tagging.TagInputField,
Produces and error saying CQ.tagging is undefined. Is there a way for me to extend this file in CQ5? If so what am I doing wrong?
Within /libs/cq/tagging/widgets/source/widgets/TagInputField.js, you'll see that the tags widget is declared as CQ.tagging.TagInputField, so I believe your second approach of extending that field is correct.
You mentioned that your custom xtype is in a separate file - when your page loads and your extension code is invoked, has the tagging widgets library loaded? You may need to add the tagging category to your custom client lib as a dependency.
On custom JS clientlibs and dependencies:
http://helpx.adobe.com/cq/kb/HowToCreateCustomClientLib.html