In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces python how to collect Baidu search results with specific URL links, the article is very detailed, has a certain reference value, interested friends must read it!
# coding utf-8import requestsfrom bs4 import BeautifulSoup as bsimport refrom Queueimport Queueimport threadingfrom argparse import ArgumentParserarg = ArgumentParser (description='baidu_url_collet py-script by xiaoye') arg.add_argument ('keyword',help='keyword like inurl:?id=for searching sqli site') arg.add_argument Default=10) arg.add_argument ('- User-Agent':'Mozilla/5.0 (windows NT 10.0 WX64) result = arg.parse_args () headers = {'User-Agent':'Mozilla/5.0 (windows NT 10.0 WX64) Rv:50.0) Gecko/20100101 Firefox/50.0'} class Bg_url (threading.Thread): def _ _ init__ (self,que): threading.Thread.__init__ (self) self._que = que def run (self): while not self._que.empty (): URL = self._que.get () try: self.bd_url_collet (URL) except Exception E: print (e) pass def bd_url_collect (self, url): r = requests.get (url, headers=headers, timeout=3) soup = bs (r.content, 'lxml', from_encoding='utf-8') bqs = soup.find_all (name='a', attrs= {' data-click':re.compile (ritual.') 'class':None}) # get the link to the a tag searched from Baidu for bq in bqs: r = requests.get (bq [' href'], headers=headers, timeout=3) # get the real link if r.status_code = = 200 print r.url with open # if the status code is 200 print r.url with open (result.outfile 'a') as f: f.write (r.url +'\ n') def main (): thread = [] thread_count = result.thread_count que = Queue () for i in range (0 (result.pagecount-1) * 10for i in thread 10): que.put ('https://www.baidu.com/s?wd=' + result.keyword +' & pn=' + str (I)) or i in range (thread_count): thread.append (Bd_url (que)) for i in thread: i.start () for i in thread: i.join () if _ name__ = ='_ main__': main () # execute The format python aaaaa.py "inurl:asp?id="-p 30-t 30 and above are all the contents of the article "how python collects Baidu search results with links with specific URL" 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.