Chevereto free\u7248\u672c \u4f7f\u7528api \u4e0a\u4f20\u56fe\u7247 \u56fe\u6587\u6559\u7a0b<\/a><\/p>\n\u6ce8\uff1a\u8001\u5b63\u662fPython\u65b0\u624b\uff0c\u5982\u6709\u4e0d\u5bf9\u7684\u5730\u65b9\uff0c\u5e0c\u671b\u5927\u795e\u6307\u51fa\u3002<\/p>\n
\u4e0b\u9762\u5c06python\u811a\u672c\u5f00\u6e90\uff1a<\/p>\n
#!\/usr\/bin\/python\r\n# -*- coding: UTF-8 -*-\r\n# \u4f5c\u8005\uff1a\u8001\u5b63\r\n# \u7f51\u5740\uff1ahttp:\/\/jiloc.com\/43112.html\r\n\r\n#\u5bfc\u5165\u6240\u9700\u7684\u5e93\r\nfrom bs4 import BeautifulSoup\r\nfrom urllib.parse import urlencode\r\nimport urllib.request,socket,re,sys,os,json,time,threading,queue\r\n\r\n\r\n\r\n# \u83b7\u53d6\u5355\u9875\u56fe\u7247\u65b9\u6cd5\r\ndef getImage(url): \r\n # \u7f51\u5740\r\n if url == '':\r\n print('URL NULL')\r\n sys.exit()\r\n print(url)\r\n print('--- Begin to Crawl Url ---')\r\n req = urllib.request.Request(url)\r\n res = urllib.request.urlopen(req)\r\n data = res.read()\r\n for link,t in set(re.findall(r'(http:\/\/img3.doubanio.com\/view\/group_topic\/large\/public\/[^s]*?(jpg))', str(data))):\r\n if link != '' :\r\n http_status = http_get(link)\r\n print( link + ' -> '+ http_status )\r\n# print(link)\r\n print('--- End to Crawl Url ---')\r\n\r\n\r\n\r\n# \u83b7\u53d6\u9875\u9762\u7684url\u5730\u5740\u5e76\u4f7f\u7528getImage\u65b9\u6cd5\u6293\u53d6\u56fe\u7247\r\ndef getUrlList(url):\r\n data=urllib.request.urlopen(url).read() \r\n soup = BeautifulSoup(data, \"html.parser\")\r\n tdList = soup.find_all(\"td\",class_='title') \r\n for i in tdList:\r\n title = i.a.get(\"title\")\r\n if len(i.contents) > 1:\r\n i_href = i.a.get('href')\r\n getImage(i_href)\r\n\r\n\r\n\r\n# \u6a21\u62df\u6d4f\u89c8\u5668\u63d0\u4ea4\u6570\u636e\r\ndef http_get(url):\r\n submit_url = 'http:\/\/788to.com\/api\/1\/upload\/?key='+urllib.parse.quote_plus('API\u503c')+'&source='+urllib.parse.quote_plus(url)\r\n# print(submit_url)\r\n req = urllib.request.Request(submit_url)\r\n try:\r\n res = urllib.request.urlopen(req)\r\n except urllib.error.HTTPError as e:\r\n print(e.read()) \r\n sys.exit()\r\n # .decode('ascii') : \u5c06byte\u7c7b\u578b\u8f6c\u5316\u4e3a\u5b57\u7b26\u4e32\u683c\u5f0f\r\n# return res.read().decode('ascii')\r\n data = json.loads(res.read().decode())\r\n return str(data['status_code'])\r\n\r\n\r\n\r\n#getUrlList('http:\/\/www.douban.com\/group\/meituikong\/discussion?start=400')\r\n\r\nprint('\u7fa4\u7ec4\u8d77\u59cb\u5730\u5740\u793a\u4f8b\uff1ahttp:\/\/www.douban.com\/group\/meituikong\/discussion?start=')\r\ntheUrl = str(input(\"\u8bf7\u8f93\u5165\u8c46\u74e3\u9996\u9875\u5730\u5740\uff1a\"))\r\ntheEnd = int(input('\u8bf7\u8f93\u5165\u6700\u540e\u4e00\u9875\u7684start\u6570\u5b57\u503c\uff1a'))\r\n\r\nclass jdThread(threading.Thread):\r\n def __init__(self,index,queue):\r\n threading.Thread.__init__(self)\r\n self.index = index\r\n self.queue = queue\r\n \r\n def run(self):\r\n while True:\r\n time.sleep(1)\r\n item = self.queue.get()\r\n if item is None:\r\n break\r\n# print(\"\u5e8f\u53f7\uff1a\",self.index,\"\u4efb\u52a1\",item,\"\u5b8c\u6210\")\r\n getUrlList(theUrl+str(item*25))\r\n time.sleep(1)\r\n self.queue.task_done() #task_done\u65b9\u6cd5\u4f7f\u5f97\u672a\u5b8c\u6210\u7684\u4efb\u52a1\u6570\u91cf-1\r\n if q.empty(): return\r\n\r\n\r\n\r\nq = queue.Queue(0)\r\n'''\r\n\u521d\u59cb\u5316\u51fd\u6570\u63a5\u53d7\u4e00\u4e2a\u6570\u5b57\u6765\u4f5c\u4e3a\u8be5\u961f\u5217\u7684\u5bb9\u91cf\uff0c\u5982\u679c\u4f20\u9012\u7684\u662f\r\n\u4e00\u4e2a\u5c0f\u4e8e\u7b49\u4e8e0\u7684\u6570\uff0c\u90a3\u4e48\u9ed8\u8ba4\u4f1a\u8ba4\u4e3a\u8be5\u961f\u5217\u7684\u5bb9\u91cf\u662f\u65e0\u9650\u7684.\r\n'''\r\nfor i in range(2):\r\n jdThread(i,q).start()#\u4e24\u4e2a\u7ebf\u7a0b\u540c\u65f6\u5b8c\u6210\u4efb\u52a1\r\n\r\nfor i in range( int( theEnd\/25) ):\r\n q.put(i)#put\u65b9\u6cd5\u4f7f\u5f97\u672a\u5b8c\u6210\u7684\u4efb\u52a1\u6570\u91cf+1\r\n<\/pre>\n <\/p>\n","protected":false},"excerpt":{"rendered":"
\u6700\u8fd1\u6ca1\u4e8b\u5f04\u4e86\u4e00\u4e2a\u56fe\u5e8a\uff08http:\/\/788to.com\uff09\uff0c\u7136\u540e\u53c8\u6bd4\u8f83\u559c\u6b22\u8c46\u74e3\u5c0f\u7ec4\u91cc\u7684\u56fe\u7247\uff0c\u6240\u4ee5\u5c31\u60f3\u4ece\u8c46\u74e3\u5c0f\u7ec4\u6293 […]<\/p>\n","protected":false},"author":1,"featured_media":43113,"comment_status":"open","ping_status":"closed","sticky":false,"template":"single-with-sidebar","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[163,46,157,13,146,129,109],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/jiloc.com\/wp-json\/wp\/v2\/posts\/43112"}],"collection":[{"href":"http:\/\/jiloc.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/jiloc.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/jiloc.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/jiloc.com\/wp-json\/wp\/v2\/comments?post=43112"}],"version-history":[{"count":0,"href":"http:\/\/jiloc.com\/wp-json\/wp\/v2\/posts\/43112\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/jiloc.com\/wp-json\/wp\/v2\/media\/43113"}],"wp:attachment":[{"href":"http:\/\/jiloc.com\/wp-json\/wp\/v2\/media?parent=43112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/jiloc.com\/wp-json\/wp\/v2\/categories?post=43112"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/jiloc.com\/wp-json\/wp\/v2\/tags?post=43112"}],"curies":[{"name":"wp","href":"http:\/\/api.w.org\/{rel}","templated":true}]}}