I want to download all the images of my boards on pinterest - python

I am now trying to download all the images on the board using selenium.
However, I am unable to log in.
How should I click on this and enter my ID:Pass?
<div data-test-id="login-button">

You can use
driver.find_element(By.CSS_SELECTOR, "div[data-test-id='login-button']")

Related

Webscraping site that downloads a file in Python

I'm trying to scrape a table from a website.
I obviously get the XPATH of the table to use in the Selenium driver - but the website already produces a file which we can download of the same table.
I click on an icon and it opens a SAVE AS dialog box.
Using selenium, how can I just download this file? How do I just save it directly?
According to older posts, some degree of input is emulated. (using pyautogui). Probably just an enter key on keyboard.
https://stackoverflow.com/a/58432097/19042045

Not able to scrape embedded YouTube video from website

I am trying to scrape this(marked in red in attached image) embedded YouTube video from " https://www.akrapovic.com/en/car/product/86/Ferrari/458-Italia-458-Spider/Slip-On-Line-Titanium?brandId=20&modelId=70&yearId=3945" but am not able to find its source or any YouTube link to scrape.
Code I've written to get is as follows. Unfortunately, all it does is throws an 'NoSuchElementException'.Please suggest me best way to go about with this. Thanks in advance.
driver.get(part_page_link_holder3)
video_holder = driver.find_element(By.CSS_SELECTOR, 'video-fullscreen')
driver.execute_script("arguments[0].click();", video_holder)
video_holder2 = driver.find_element(By.XPATH,'//iframe')
print(video_holder2)
It is visible in the code after looking through inspect. It only shows up after clicking the play button on the video though.

How can I get the text between <span></span> using Selenium importing webdriver?

I tried using driver.find_elements_by_xpath("//*[contains(text(), 'Hello Bot)]"), but no luck!
I am trying to make a whatsapp bot that takes another user's input as information which is why I want it so that when "Hello Bot" is stated, it initializes the bot
If you are viewing page source you can right click on span and select Copy > Copy full XPath, then paste it into your code.

Can't click on webpage element using python selenium when used with mobile user-agent

I am trying to automate clicking on the play button of an embedded iframe music player on a webpage, I am coding using python 3 and Selenium to select the element to click.
When the user-agent is changed to replicate a mobile device, a wrapper layer then obscures the button that I can normally click, it asks if I want to listen on the main site or in the browser. I want to listen in the browser, but so far everything I have tried to click the correct element to achieve that, has failed.
I believe I am clicking on the wrong part but cannot find a way to access the correct part.
The inspect window of the browser shows the below for the part of the wrapper I need to click on:
<a class="mobilePrestitial__link sc-font-light" href="#">
Listen in browser
</a>
::before
"
Listen in browser
"
/a>
When I hover over the ::before part it highlights the part in the browser that I believe I need to click, but using right-click to inspect ::before just says 'scroll in view' so I cannot copy whatever the element represents.
My current code is this:
driver.switch_to.default_content()
driver.switch_to.frame(driver.find_element_by_partial_link_text('Listen in browser'))
element = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, '//a[#class="mobilePrestitial__link"]'))
)
element.click()
But it errors without a message, I suspect I need to be clicking on the element presented by ::before but cannot figure how to do that.
I found a workaround and solved this by hiding the wrapper overlay using Selenium in python script to make a Javascript call
driver.execute_script('document.getElementsByClassName("mobilePrestitial")[0].style.display=\"none\"')
once the overlay is hidden with the above code, the original button is accessible in the browser

Selenium and Javascript

I'm trying to learn how to use selenium. I'm trying to work on creating script to like instagram photos; however, i'm running into a problem where xpath won't detect the image i want to click. I think this is probably due to the fact it's a javascript button.
This is a picture of the element i am inspecting. There's multiple pictures on the site and i am given the line
<a class="thumb-shadow" href="javascript:void(0);"></a>
https://gyazo.com/558df373e6ac426f098759665fd8f918
I've tried clicking the xpath of image wrapper, but it doesn't work either. How can i click the javascript item? Are there any resources you can point me to?
Thanks
Try driver.find_element_by_xpath("//a[#class='thumb-shadow']/img").c‌​lick()

Categories