Hello Team,
I'm facing an issue. While scraping the data from a website, few elements like pop-ups, some promotional ads etc. are breaking the script which is making scraping harder. Earlier I've used to xpath to close the pop-ups but again the in-line promotional ads & irrelevant element are messing up with the script. I figured out if I delete the elements before itself from the chrome's inspect element while pausing the script using "Messagemodal", it solves the problem. I would like to know how to delete the certain elements like this directly using the script. An example would be great for help.
Regards,
Ushahra
How to delete an element from a webpage in chrome
Moderators: Dorian (MJT support), JRL
Re: How to delete an element from a webpage in chrome
Hi Team,
I have figured out a way, I injected JS code to Chrome console to remove the irrelevant element using following code.
Its Subroutine program:
Its working perfectly fine.
Thanks & Regards
I have figured out a way, I injected JS code to Chrome console to remove the irrelevant element using following code.
Code: Select all
GoSub>ExecuteJS,s1,document.getElementById("reactExitIntent").remove();
Code: Select all
SRT>ExecuteJS
Let>HTTP_POSTJSON=1
Let>body= { "script": "%ExecuteJS_Var_2%", "args": [] }
//if you are not using the standard port and have changed it with CHROMEDRIVER_PORT then change the port number here accordingly
HTTPRequest>http://localhost:9515/session/%ExecuteJS_Var_1%/execute,,POST,body,theResult
END>ExecuteJS
Thanks & Regards
Re: How to delete an element from a webpage in chrome
I have another issue if anyone can help.
During the webpage scrapping on Chrome browser, there are few popups (in-page popup) which doesn't show up until I navigate on the pages for 30-40 seconds. When it shows up in the middle of the task, the script starts giving blank values instead of the actual data. I couldn't wait for the popup to show up and then close it in order to start scrapping.
Can anyone help me with this, how to either block the popups before stating the script or identify the when popup appears so the script automatically close it & move further?
Thanks!
During the webpage scrapping on Chrome browser, there are few popups (in-page popup) which doesn't show up until I navigate on the pages for 30-40 seconds. When it shows up in the middle of the task, the script starts giving blank values instead of the actual data. I couldn't wait for the popup to show up and then close it in order to start scrapping.
Can anyone help me with this, how to either block the popups before stating the script or identify the when popup appears so the script automatically close it & move further?
Thanks!