Python Selenium爬取有道网页翻译后的页面

发表时间:2019-12-22

Snipaste_2019-12-22_21-32-53.png


完整脚本:

#https://www.pythonf.cn/
# -*- coding: utf-8 -*-

from selenium import webdriver

url = 'https://www.pcmag.com/review/371666/lg-g8x-thinq-dual-screen'

driver = webdriver.Chrome("d:/chromedriver/chromedriver.exe")
# 获取数据
def login(url):
driver.get('http://fanyi.youdao.com')
driver.find_element_by_id('inputOriginal').send_keys(url)
driver.find_element_by_id('transMachine').click()
driver.switch_to.frame("iframe")
print(driver.find_element_by_name('intellitxt').text)


if __name__ == "__main__":
login(url)

运行脚本直接可以打印翻译后的正文内容


Python Free

邮箱:417803890@qq.com
QQ:417803890

皖ICP备19001818号
© 2019 copyright www.pythonf.cn - All rights reserved

微信扫一扫关注公众号:

联系方式

Python Free