python中点击页面的验证码
我有以下html代码:python中点击页面的验证码,python,web-scraping,click,Python,Web Scraping,Click,我有以下html代码: <input id="luk" type="button" class="play-bt" value="Click Here To Generate Link"> 但我不知道下一步该怎么办,使用硒对我来说不是一个好方法,帮帮我!! 谢谢你可以用它来实现这一点 from bs4 import BeautifulSoup s = '''<iframe src="LINK_WEB" scrolling="no" frameborder="0" width
<input id="luk" type="button" class="play-bt" value="Click Here To Generate Link">
但我不知道下一步该怎么办,使用硒对我来说不是一个好方法,帮帮我!!
谢谢你可以用它来实现这一点
from bs4 import BeautifulSoup
s = '''<iframe src="LINK_WEB" scrolling="no" frameborder="0" width="100%" height="100%" allowfullscreen="true">'''
soup = BeautifulSoup(s, 'lxml')
iframe_tags = soup.find_all('iframe')
for iframe in iframe_tags:
print(iframe.src)
如果您没有使用
Selenium
,则可以使用请求
库获取页面源代码。但是,s仅在我单击“”时显示,如何单击此?单击之前的url与单击之后的url相同。然后,下载(url)单击“捕获新html with”,尝试使用find_element_by_xpath
方法,使用以下模式:'//input[/@value=“单击此处生成链接”]
。通过这种方式,您将有望找到元素并可以。单击()
它以获得驱动程序。page\u source
。使用beautifulsoup可以做到这一点吗?您不能使用bs4
与页面交互。。。您可以通过组合使用selenium+bs4
来实现这一点。是否需要使用selenium?(还有别的图书馆吗?)
try:
boton = driver.find_element_by_id("luk")
boton.click()
except:
print "Element is not present"
from bs4 import BeautifulSoup
s = '''<iframe src="LINK_WEB" scrolling="no" frameborder="0" width="100%" height="100%" allowfullscreen="true">'''
soup = BeautifulSoup(s, 'lxml')
iframe_tags = soup.find_all('iframe')
for iframe in iframe_tags:
print(iframe.src)
s = driver.page_source