爬虫
wto882dim
这个作者很懒,什么都没留下…
展开
-
Python类中函数传入不固定参数的应用
class Employee: def __init__(self, fullname, **kwargs): self.name, self.lastname = fullname.split() self.__dict__.update(kwargs) # 更新对象john = Employee("John Doe")mary = Employee("Mary Major", salary=10000, height=178, weight=65..原创 2022-04-16 19:20:40 · 770 阅读 · 0 评论 -
Python 使用Selenium webdriver chromedriver实现点击click()的三种方法
Python 使用Selenium webdriver chromedriver实现点击click()的三种方法原创 2022-02-21 23:34:29 · 5203 阅读 · 0 评论 -
python selenium提取标签中的@href链接
python selenium提取标签中的@href链接import requestsfrom selenium import webdriverimport time# 西瓜美食频道# url = "https://www.ixigua.com/channel/meishi/"# 取到当前的textdef get_source(url): browser = web...原创 2020-02-24 15:58:09 · 5701 阅读 · 5 评论 -
python爬取所有A股个股代码与股名并保存为excle格式
使用requests, lxml, xlwt库,完成任务利用pip3 install库名 安装各种第三方库import requestsfrom lxml import etreeimport xlwtheaders = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ...原创 2019-11-29 18:15:25 · 1010 阅读 · 0 评论 -
xpath的特殊而好用的二个语法
# td节点不包含id属性的其他属性stock_list_field = e.xpath('//div[@id="quote-digest"]/table/tbody/tr/td[not(@id)]/text()')# td节点包含id属性且包含有"gt"内容的所有属性stock_list = e.xpath('//div[@id="quote-digest"]/table/...原创 2019-11-28 17:36:04 · 129 阅读 · 0 评论 -
python使用pymysql把数据写入mysql
简单粗暴直接上代码:import pymysqlimport requestsfrom lxml import etreeheaders = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Saf...原创 2019-11-27 23:41:35 · 1966 阅读 · 0 评论 -
python下载文件时自制下载进度条
进度条的关键点就是深刻理解print()函数print('\r') #换行print(end='') #不换行输出只要利用好这二个,听起来就有点乱了!那就直接上代码吧!结果:(动态图没有放上来)[文件大小]: 20.38 MB[下载进度]:>>>>>>>>>>>>>>>>&g...原创 2019-10-26 00:59:03 · 1186 阅读 · 2 评论 -
scrapy 服务器中使用无头selenium 解析网页
scrapy使用selenium以下是middlewares.py代码from selenium import webdriverimport timefrom scrapy.http.response.html import HtmlResponseclass SeleniumDownloadMiddleware(object): def __init__(self...原创 2019-09-23 18:15:31 · 576 阅读 · 0 评论 -
Mac 通过brew安装selenium和chromedriver
1,安装seleniumpip3 install selenium使用dirver = webdriver.Chrome()时会报错:WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/...原创 2019-08-22 19:34:47 · 890 阅读 · 0 评论 -
ubuntu httrack 下载整个网站
安装httracksudo apt install httrack进入命令:httrack 安提示操作原创 2019-01-01 01:24:11 · 850 阅读 · 0 评论 -
pyspider 使用 PhantomJS 渲染带 JS 的页面
pyspider 爬虫教程(三):使用 PhantomJS 渲染带 JS 的页面英文原文:http://docs.pyspider.org/en/latest/tutorial/Render-with-PhantomJS/在上两篇教程中,我们学习了怎么从 HTML 中提取信息,也学习了怎么处理一些请求复杂的页面。但是有一些页面,它实在太复杂了,无论是分析 API 请求的地址,还是渲染时进行...转载 2018-09-08 13:11:17 · 1320 阅读 · 0 评论