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 how to grab Taobao IP address data, the article is very detailed, has a certain reference value, interested friends must read it!
Sample code
Def fetch (ip): url = 'http://ip.taobao.com/service/getIpInfo.php?ip=' + ip result = [] try: response = urllib.urlopen (url). Read () jsondata = json.loads (response) if jsondata [u' code'] = 0: result.append (jsondata [u 'data'] [upriip'] .encode (' utf-8')) Result.append (jsondata [u 'data'] [upright roomy'] .encode (' utf-8')) result.append (jsondata [u 'data'] [upright roomyroomid'] .encode (' utf-8')) result.append (jsondata [u 'data'] [upright area'] .encode (' utf-8')) result.append (js ondata [u 'data'] ] .encode ('utf-8')) result.append (jsondata [u' data'] [upright region'] .encode ('utf-8')) result.append (jsondata [u' data'] [upright regionregiid'] .encode ('utf-8')) result.append (jsondata [u 'data'] [upright city'] .encode ('utf-8')) Result.append (jsondata [u 'data'] [upright citytellid'] .encode (' utf-8')) result.append (jsondata [u 'data'] [upriscounty'] .encode (' utf-8')) result.append (jsondata [u 'data'] [upright countyroomid'] .encode (' utf-8') result.append (j Sondata [u 'data']] Encode ('utf-8')) result.append (jsondata [u' data'] [uflaispSecretid'] .encode ('utf-8')) else: return 0 Result except: logging.exception ("Url open failed:" + url) return 0, result return 1, result def worker (ratelimit, jobs, results, progress): global cancel while not cancel: try: ratelimit.ratecontrol () ip = jobs.get (timeout=2) # Wait 2 seconds ok, result = fetch (ip) if not ok: logging.error ("Fetch information failed Ip: {} ".format (ip) progress.put (") # Notify the progress even it failed elif result is not None: results.put (".join (result)) jobs.task_done () # Notify one item except Queue.Empty: pass except: logging.exception (" Unknown Error! ") def process (target, results Progress): global cancel while not cancel: try: line = results.get (timeout=5) except Queue.Empty: pass else: print > > target, line progress.put (") results.task_done () def progproc (progressbar, count, progress):"Since ProgressBar is not a thread-safe class, we use a Queue to do the counting job, like two other threads. Use this thread do the printing of progress bar. By the way, it will print to stderr, which does not conflict with the default result output (stdout). " Idx = 1 while True: try: progress.get (timeout=5) except Queue.Empty: pass else: progressbar.update (idx) idx + = 1 is all the content of the article "how Python grabs IP address data on Taobao". 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.