Python数据分析
2021/9/3 17:06:06
本文主要是介绍Python数据分析,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
- 爬取部分豆瓣top250
1 import requests 2 from lxml import etree 3 4 5 def getData(number): 6 url = "https://movie.douban.com/top250?start={0}".format(number) 7 headers = {"User-Agent": 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko'} 8 response = requests.get(url, timeout=10, headers=headers) 9 response.encoding = 'utf-8' 10 parser = etree.HTMLParser(encoding='utf-8') 11 html = etree.HTML(response.text, parser=parser) 12 message = html.xpath('//ol[@class="grid_view"]/li/div[@class="item"]/div[@class="pic"]/a/img/@alt') # 根据网页结构不同,自行调整 13 print(message) 14 15 16 if __name__ == '__main__': 17 # 每页25个电影,取前10页 18 for number in range(0, 250, 25): 19 getData(number)
这篇关于Python数据分析的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-28Python编程基础教程
- 2024-12-27Python编程入门指南
- 2024-12-27Python编程基础
- 2024-12-27Python编程基础教程
- 2024-12-27Python编程基础指南
- 2024-12-24Python编程入门指南
- 2024-12-24Python编程基础入门
- 2024-12-24Python编程基础:变量与数据类型
- 2024-12-23使用python部署一个usdt合约,部署自己的usdt稳定币
- 2024-12-20Python编程入门指南