![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python爬虫
SimonChenHere
PhD Candidate,计算机本,人工智能硕,网络安全博。
展开
-
Python爬虫_正则表达式小例子
import rematch = re.search(r'[1-9]\d{5}', 'BIT 100081')if match: print(match.group(0))原创 2020-04-25 14:37:15 · 7047 阅读 · 0 评论 -
BeautifulSoup的使用
from bs4 import BeautifulSoupimport requestsr = requests.get("http://www.baidu.com")demo = r.textsoup = BeautifulSoup(demo,"html.parser")print(soup.prettify())原创 2020-04-25 14:36:12 · 6859 阅读 · 0 评论 -
淘宝商品比价
# 加载requests库import requests# 加载正则表达式模块import re# 爬取网页内容模块def get_html_text(url): # 获取要访问的网址 try: r = requests.get(url, timeout=30) # 把爬取后的内容赋给r,等待时间对多30秒 r.raise_for_stat...原创 2020-04-25 14:34:31 · 1442 阅读 · 0 评论 -
利用搜索引擎实现关键词爬取内容
import requeststry: kv = {'q':'Python'}#关键词键值对,要搜索Python r = requests.get("http://www.so.com/s",params=kv) print(r.status_code) print(r.request.url) r.raise_for_status() print...原创 2020-04-25 14:31:16 · 3066 阅读 · 0 评论 -
Python股票数据定向爬虫
import requestsfrom bs4 import BeautifulSoupimport tracebackimport redef getHTMLText(url):try:r = requests.get(url)r.raise_for_status()r.encoding = r.apparent_encodingreturn r.textexcept:re...原创 2020-04-25 14:28:37 · 3452 阅读 · 0 评论