大佬教程收集整理的这篇文章主要介绍了BeautifulSoup Python Selenium - 在抓取网站之前等待推文加载,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
links = 'https://www.DW.com/en/vaccines-appear-effective-against-india-covID-variant/a-57344037'
driver.get(links)
delay = 30 #seconds
try:
webdriverwait(driver,delay).until(EC.visibility_of_all_elements_located((By.ID,"twitter-Widget-0")))
except:
pass
tweetsource = driver.page_source
tweetSoup = BeautifulSoup(tweetsource,features='HTMl.parser')
linkTweets = tweetSoup.find_all('a')
for linkTweet in linkTweets:
try:
tweetURL = linkTweet.attrs['href']
except: # pass on KeyError or any other error
pass
if "twitter.com" in tweetURL and "status" in tweetURL:
# Run getTweetID function
tweetID = getTweetID(tweetURL)
newdata = [tweetID,date_tag,"DW",links,title_tag,"News",""]
# Write to dataframe
df.loc[len(df)] = newdata
print("working on tweetID: " + str(tweetID))
@H_419_0@如果有人能让 SELEnium 找到这条推文就太好了!
这是一个 iframe
首先你需要切换到那个 iframe
iframe = WebDriverWait(driver,10).until(
EC.presence_of_element_located((By.ID,"twitter-widget-0"))
)
driver.switch_to.frame(iframE)
以上是大佬教程为你收集整理的BeautifulSoup Python Selenium - 在抓取网站之前等待推文加载全部内容,希望文章能够帮你解决BeautifulSoup Python Selenium - 在抓取网站之前等待推文加载所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。