简体   繁体   English

使用python进行网页抓取。 从网站收集数据

[英]Web scraping using python. Collecting data from a website

I am scraping some data from a website. 我正在从网站上抓取一些数据。 I am writing a script that will automate it. 我正在写一个脚本来自动化它。 In order to go to the next page I have to remove this disabled attribute from the button. 为了转到下一页,我必须从按钮中删除此禁用的属性。 I have tried many things, but nothing has helped me till now. 我尝试了很多事情,但到目前为止没有任何帮助。

<button class="proceed" disabled="disabled" >Next</button>

Code: 码:

binary = FirefoxBinary('/usr/lib/firefox/firefox')
driver = webdriver.Firefox(firefox_binary=binary)

driver.get("https://example.com/example/example")

my_url = Request('https://www.example.com/example/example', headers={'User-Agent': 'Mozilla/5.0'})
uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()
page_soup = soup(page_html, "html.parser")

user = raw_input("enter your starting point : ")

user_box = driver.find_element_by_class_name("search")
user_box.send_keys(user)
#user_box.autocomplete = "on"
#user_box.submit()

login_button = driver.find_element_by_css_selector("button.proceed")
#login_button.submit()

#print (login_button.text)

Use JavascriptExecutor to remove this disabled attribute from the button as follows : 使用JavascriptExecutor按钮中删除此disabled属性,如下所示:

login_button = driver.find_element_by_css_selector("button.proceed")
driver.execute_script("arguments[0].removeAttribute('disabled')", login_button) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM