爬虫实质是什么呢?
- 模拟浏览器的工作原理,向服务器请求相应的数据
3行代码爬取京东数据
梳理代码流程:
- (1)引入Python工具包requests
- (2)使用工具包中的get方法,向服务器发起请求
- (3)打印输出请求回来的数据(print语法)
import requests
resp=requests.get('https://club.jd.com/comment/productPageComments.action?callback=fetchJSON_comment98&productId=16878195190&score=0&sortType=5&page=0&pageSize=10&isShadowSku=0&fold=1')
print(resp.text)