Issue
I'm trying to get the Website url and Whitepaper url from the page https://coinmarketcap.com/currencies/bob/ in the left column.
I'm using BeautifulSoup soup.findAll(string='Whitepaper')
and similar but the page seems changing structure everytime. The following attempt worked fine but now it doesn't:
from bs4 import BeautifulSoup
from soup2dict import convert
import requests
url='https://coinmarketcap.com/currencies/bob/'
page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')
tag=soup.find_all(class_="link-button", recursive=True)
for t in tag:
if 'Whitepaper' in str(t):
tt=convert(t)
print(tt['@href'])
I'm also using Selenium to interact with other parts of the website, so a solution with Selenium Python is good as well.
Thank you
Solution
You can try below using selenium
from webdriver_manager.microsoft import EdgeChromiumDriverManager
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ExpectedConditions
from selenium import webdriver
url = 'https://coinmarketcap.com/currencies/bob/'
driver = webdriver.Edge(executable_path=EdgeChromiumDriverManager().install())
wait = WebDriverWait(driver, 10)
driver.get(url)
websiteButton = driver.find_element(By.XPATH, '//div[text()="Website"]')
actions = ActionChains(driver)
actions.move_to_element(websiteButton).perform()
urlElement = wait.until(
ExpectedConditions.visibility_of_element_located((By.CSS_SELECTOR, 'div[class="tippy-content"] span')))
print(urlElement.text)
Prints
www.zkbob.com
Answered By - Abhay Chaudhary
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.