😆 Hey! Welcome to my profile
🍉 Take a look at my stats 🌱
|
|
---|
《Python网络爬虫入门到实战》配套程序。爬虫项目集合,
Home Page: https://item.jd.com/14049708.html
License: MIT License
https://xiaohua.zol.com.cn/baoxiaonannv/1.html
运行代码
# 导入模块
import logging
# 匹配内容
import re
# 网页请求
import requests
# 忽略警告
logging.captureWarnings(True)
# 控制时间
import time
# 写入请求网址与请求头
url = "https://xiaohua.zol.com.cn/baoxiaonannv/%d.html"
header = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36",
}
# 正则表达式
pattern = re.compile(r'<div class="summary-text">(.*?)</div>')
duanzi = url % (1)
print(duanzi)
requests.packages.urllib3.disable_warnings()
# 获取代码内容,cerify=False不认证
response = requests.get(url=duanzi, headers=header, verify=False, timeout=10).text
# 正则匹配
item = pattern.findall(response, re.S)
time.sleep(2)
response
# print(item)
通过正则表达式<div class="summary-text">(.*?)</div>
照理来说应该这20个都匹配到了,但是为什么这3个没有匹配到?re.S
似乎能含\n
但是没有制表符\t
。是这个问题吗?那正则表达式该怎么改使得\t
也能被匹配
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.