直接上代码


import time
from selenium import webdriver  # 驱动浏览器
import re
from selenium.webdriver.support.wait import WebDriverWait
import json
browser = webdriver.Chrome(executable_path='D:\program\chromedriver_win32\chromedriver.exe')
wait = WebDriverWait(browser, 10)
# dict2=["accordingly", "consequently" ,"hence", "so" ,"therefore", "thus" ]indicators_set = ('accordingly', 'additionally', 'after', 'afterward', 'also', 'alternatively','alternative', 'although', 'as a result', 'as an alternative', 'as if', 'as long as','as soon as', 'as though', 'as well', 'because', 'before', 'before and after','besides', 'by comparison',  'but', 'by contrast', 'by then', 'consequently','conversely', 'earlier', 'either', 'except', 'finally', 'for example', 'for instance','further', 'furthermore', 'hence', 'however', 'if', 'if and when', 'in addition','in contrast', 'in fact', 'in other words',  'in particular', 'in short', 'in sum','in the end', 'in turn', 'indeed', 'insofar as', 'instead', 'later', 'lest','likewise', 'meantime', 'meanwhile', 'moreover', 'much as', 'neither','nevertheless', 'now that', 'next', 'nonetheless', 'nor', 'on the contrary', 'on the one hand','on the other hand', 'once', 'otherwise', 'overall', 'plus', 'previously', 'rather', 'regardless','separately', 'similarly', 'simultaneously', 'since', 'so that', 'specifically','still', 'then', 'thereafter', 'thereby', 'therefore', 'though', 'thus','till', 'ultimately', 'unless', 'until', 'when', 'when and if', 'whereas', 'while','yet', 'above', 'conclusion', 'agree', 'admittedly')def mysp(word):try:time.sleep(0.5)browser.get('https://fanyi.baidu.com/#en/zh/%s'%word)try:browser.find_element_by_xpath('/html/body/div[1]/div[7]/div/div/a[2]').click()except:passtime.sleep(0.5)data=browser.find_element_by_class_name('synonym-title').textprint(data)res =re.match("[\w\s]*",data).group().strip().split(" ")return resexcept:return [word]last= {}
for i in indicators_set:print(i)last[i]=mysp(i)print(last)
with open("indicators_dict.json","w") as f:json.dump(last,f)

关于selenium的安装参考

爬百度翻译的英文同义词相关推荐

  1. python爬百度翻译-Python爬取百度翻译(利用json提取数据)

    本篇文章给大家带来的内容是关于Python爬取百度翻译(利用json提取数据),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. 工具:Python 3.6.5.PyCharm开发工具. ...

  2. python爬百度翻译-爬虫 python爬取百度翻译接口 超详细附源码

    前言 今天教大家如何利用 firefox 分析百度翻译的接口,并用python爬取接口.大家学会后可以干一些有趣的事情,比如做一个自己的翻译软件. 具体内容 1 - 找到URL接口 进入百度翻译的网址 ...

  3. python爬百度翻译-教大家用python爬取百度翻译,超简单

    一,首先导入urllib里面的request和parse:这里导入parse主要字符转码 from urllib import request,parse 二,爬取别人的网站最好加入伪装,也就是浏览器 ...

  4. python爬百度翻译-用python实现百度翻译

    用python实现百度翻译 首先,需要简单的了解一下爬虫,尽可能简单快速的上手,其次,需要了解的是百度的API的接口,搞定这个之后,最后,按照官方给出的demo,然后写自己的一个小程序 打开浏览器 F ...

  5. python爬百度翻译-Python爬虫实现百度翻译功能过程详解

    首先,需要简单的了解一下爬虫,尽可能简单快速的上手,其次,需要了解的是百度的API的接口,搞定这个之后,最后,按照官方给出的demo,然后写自己的一个小程序 打开浏览器 F12 打开百度翻译网页源代码 ...

  6. python爬百度翻译-python爬虫实现百度翻译

    简述: 最近在学习python,就开始研究爬虫,写了个简单的程序 实现功能: 百度翻译 思路: 通过浏览器的开发者工具,发现百度翻译的接口和翻译所需要发送的数据包,通过python实现模拟浏览器进行百 ...

  7. python爬百度翻译-python爬取百度翻译的问题以及解决方案

    #query = '你好,世界' sign = execjs.compile(jsCode).call("e", query )print(sign) data={"fr ...

  8. 百度翻译sign签名算法

    很多小伙伴都想去爬百度翻译,然后发现sign这个js生成的值却过不了,没关系,接下来的3分钟让你轻松的完成百度sign破解 第一步还是老样子,全局查找sign,给他赋值的地方打上断点 我们可以清楚的看 ...

  9. requests基操/爬取调用百度翻译

    因为最近使用pandas 和numpy,所以就研究下requests库,毕竟这是目前python最流行的http请求库,也是最符合pythonic的库,有时间也准备看源码学习下,不过前一阵看到一个ht ...

最新文章

  1. R语言gganimate包创建可视化gif动图、并使用anim_save函数保存可视化gif动图(gganimate export to gif)
  2. Lintcode363 Trapping Rain Water solution 题解
  3. jquery实现在元素外单击,隐藏此元素
  4. CNZZ数据专家使用方法?
  5. js输出一个菱形_Webpack 4入口、输出和ES6模块
  6. PHP常用的正则表达式(有些需要调整)
  7. RabbitMQ+PHP 教程六(RPC)
  8. jsp mysql 音乐网站_Maven+JSP+SSM+Mysql实现的音乐网站
  9. [css] 写出你知道的CSS水平和垂直居中的方法
  10. Docker 数据管理介绍
  11. nodejs对文件进行分页
  12. button3 电脑上mouse_专栏F|Cora单词168电脑(下):最强大脑,智慧的产物
  13. 海量数据库解决方案2011040701
  14. 雷达信号处理基础 ch1 note1
  15. 【STM32H7的DSP教程】第5章 Matlab简易使用之常用编程语句
  16. 微信js-sdk+JAVA实现分享接口
  17. 调焦后焦实现不同距离成像_可调焦自适应光学扫描激光眼底成像系统设计
  18. unity+vuforia无法识别图片的解决方法
  19. 改纸盒大小_包装纸箱改大小
  20. ubuntu阿里云盘(小白羊)

热门文章

  1. Linux|文本处理三剑客之sed命令详解
  2. Android 开发学习记录(4)---- httpclient使用(三)
  3. 山西计算机专业英语,计算机专业英语(必懂)
  4. centos 5.6 安装HP打印机--成功版本
  5. EPS行业-预发机的WinFrom控制软件
  6. HTTP HTTPS 协议
  7. macbook air2018 安装win10
  8. 个人作业--四则运算3(PSP)
  9. delphi多线程释放
  10. .net core 监听文件夹变化, FileSystemWatcher 封装