In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces python multi-thread how to climb cat's eye movie, the article is very detailed, has a certain reference value, interested friends must finish!
Through the multithreading of python3, the top100 movie list of cat's eye movies is obtained, and the information is saved locally, using the requests library and regular expressions.
#! / usr/bin/env python#-*-coding: utf-8-*-# @ Author: Aiker Zhao# @ Date: 2:52 on 2019-4-2 AM# @ File: pamaoyan.py# @ Desc: import requestsfrom requests.exceptions import RequestExceptionimport reimport jsonfrom multiprocessing import Pooldef get_one_page (url): try: response = requests.get (url) if response.status_code = = 200: return response.text Return None except RequestException: return Nonedef parse_one_page (html): pattern = re.compile ('. *? board-index.*? > (\ d +). *? data-src= "(. *?)". *? name "> (. *?). *? star" > (. *?)
'+'. *? releasetime "> (. *?) (. *?). Re.S) pattern1 = re.compile ('board-index.*? > (\ d +). *? data-src=" (. *?) ". *? name" > (. *?). Star "> (. *?)
', re.S) items = re.findall (pattern, html) # print (items) for item in items: yield {' index': item [0], 'score': item [5] + item [6],' image': item [1], 'title': item [2],' actor': item [3] .strip () [3:] 'time': item [4] [5:]} def write_to_file (content): with open (' result.txt', 'asides, encoding='utf-8') as f: f.write (json.dumps (content) Ensure_ascii=False) +'\ n') f.close () def main (offset): url = 'https://maoyan.com/board/4?offset=' + str (offset) html = get_one_page (url) # print (html) for item in parse_one_page (html): print (item) write_to_file (item) if _ name__ = =' _ main__': # For i in range (10): # main (iTunes 10) pool = Pool () pool.map (main [I * 10 for i in range (10)]) these are all the contents of the article "how does python multithread climb Cat's Eye Movie" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.