![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python爬虫笔记
狮子雨恋
这个作者很懒,什么都没留下…
展开
-
Python尝试爬取同花顺A股行情
尝试爬取,目前只提取了一部分数据。在数据存储上还是有问题,还未体现Python的间接性质。如果你有好的建议请留言或私信,谢谢。下面的程序仅做参考,如果有时间再优化吧。# -- coding: utf-8 -*-"""Created on Fri Oct 30 13:18:23 2020@author: YuDi"""import requestsfrom lxml import etreeimport xlwtheaders = { 'User-Agent':'Mozill原创 2020-10-30 21:43:39 · 1339 阅读 · 2 评论 -
Python xpath爬取天气预报与存储
直接放上代码吧import requestsfrom lxml import etreeimport timeimport xlwtheaders = { 'User-Agent':'Mozilla/5.0'}url = "http://www.weather.com.cn/weather/101280101.shtml"response = requests.get(url,headers=headers)content = response.content.decode('ut原创 2020-10-28 16:36:21 · 444 阅读 · 0 评论 -
Python 天气预报写入Excel中
程序参考:SPOTO世博在线教育import requestsfrom bs4 import BeautifulSoupimport xlwtimport timeheaders = { 'User-Agent':'Mozilla/5.0'}url = "http://www.weather.com.cn/weather/101270101.shtml"weather_str = requests.get(url,headers = headers)weather_str_cont原创 2020-10-28 10:53:26 · 497 阅读 · 0 评论 -
python 爬虫 酷狗500TOP
import requestsfrom bs4 import BeautifulSoupimport timeheaders = {"User-Agent":"Mozilla/5.0"}def get_info(url): wb_data = requests.get(url,headers=headers) soup = BeautifulSoup(wb_data.tex...原创 2019-10-27 10:20:18 · 335 阅读 · 0 评论 -
python 爬虫之“盗亦有道”
最近有一条消息炸了,因为一段爬虫代码,整个公司200多人被短了。那么什么爬虫是违法的?如果爬虫程序采集到个人信息并将之用于非法途径的,则构成非法获取公民个人的违法行为。重点关注:以下情况,爬虫可能违法,严重的甚至构成犯罪。爬虫程序规避网站经营者设置的反爬虫措施或者破解服务器防抓取措施,非法获取相关信息,情节严重的,有可能构成“非法获取计算机信息系统数据罪”。2.爬虫程序干扰被访问的网站...原创 2019-10-18 23:09:36 · 305 阅读 · 0 评论 -
python 爬虫之requests笔记
准备工作安装好pycharm,requests库requests 爬虫程序(模板)import requestsdef getHTMTText(url): try: r=requests.get(url,timeout=30) r.raise_for_status() #如果状态不是200,引发HTTPError异常 r.enco...原创 2019-10-18 09:27:49 · 139 阅读 · 0 评论