淘宝密码(爬虫爬取淘宝美食的数据源码)
正则匹配找规律
import re
import requests
# 在搜索框中输入美食得到的数据q=%E7%BE%8E%E9%A3%9F
url = 'https://s.taobao.com/search?q=%E7%BE%8E%E9%A3%9F'
response = requests.get(url)
# print(response.text)
# 用正则对html源码进行解析到一个json数据
pattern = re.compile('g_page_config =(.*?);', re.S)
result = re.search(pattern, response.text)
# print(result.group(1))
# 发现并不是那么简单而是加密的数据并是有规律可寻的,以下是加密的几个数据段
json_data = re.sub('(\\\\u003d)|(\\\\u0026)|(\\\\u003c)|(\\\\u003e)', '', result.group(1))
相关文章:
- scrapy 淘宝 爬虫 2021-07-15
- 抓取淘宝美食数据 2021-07-10
- 爬虫:淘宝价格 2021-11-18
- 爬取淘宝交易记录的爬虫 2022-12-23
- python爬虫-淘宝商品密码(图文教程附源码) 2021-12-16
- 淘宝直播数据爬取 + 淘宝模拟登陆 2021-12-16
- python爬虫爬取淘宝天猫商品评论数据教程(附源码) 2021-12-04