{"id":34,"date":"2021-04-10T06:44:28","date_gmt":"2021-04-09T22:44:28","guid":{"rendered":"https:\/\/saveweb.othing.xyz\/iamwu555\/archives\/34"},"modified":"2021-06-05T23:10:20","modified_gmt":"2021-06-05T15:10:20","slug":"%e8%ae%b0%e4%b8%80%e6%ac%a1%e7%88%ac%e8%99%ab","status":"publish","type":"post","link":"https:\/\/blog.save-web.org\/iamwu555\/archives\/34","title":{"rendered":"\u8bb0\u4e00\u6b21\u722c\u866b"},"content":{"rendered":"<p>\u8ddd\u79bb403\u5df2\u7ecf\u8fc7\u53bb\u4e86\u4e24\u5c0f\u65f6\u5de6\u53f3\uff0c\u6211\u53c8\u53ef\u4ee5\u8bbf\u95ee\u4e86\uff01\uff01<\/p>\n<p>\u672c\u7740\u505a\u4e00\u4e2a\u80fd\u8ba9\u535a\u5ba2\u80cc\u666f\u968f\u673a\u56fe\u7247\u7684api\u7684\u60f3\u6cd5\uff0c\u6211\u5f00\u59cb\u4e86\u4eba\u751f\u4e2d\u7b2c\u4e00\u6b21\u722c\u866b\u3002\u4e0a\u4e2a\u661f\u671f\u521a\u5b66\u7684Python\u722c\u866b\uff0c\u8fd8\u6ca1\u5b66\u5b8c\u6280\u672f\u5c5e\u5b9e\u6709\u70b9\u4e0d\u5230\u4f4d\uff0c\u6d4b\u8bd5\u7684\u6b21\u6570\u591a\u4e86\u70b9\uff0c\u7136\u540e\u5c31\u88ab\u5c01ip\u4e86\uff01\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-348\" src=\"https:\/\/saveweb.othing.xyz\/iamwu555\/wp-content\/uploads\/sites\/5\/2021\/04\/20203241-8352527.jpg\" width=\"1916\" height=\"314\" alt=\"20203241-8352527\" title=\"20203241-8352527\" srcset=\"https:\/\/blog.save-web.org\/iamwu555\/wp-content\/uploads\/sites\/5\/2021\/04\/20203241-8352527.jpg 1916w, https:\/\/blog.save-web.org\/iamwu555\/wp-content\/uploads\/sites\/5\/2021\/04\/20203241-8352527-300x49.jpg 300w, https:\/\/blog.save-web.org\/iamwu555\/wp-content\/uploads\/sites\/5\/2021\/04\/20203241-8352527-1024x168.jpg 1024w, https:\/\/blog.save-web.org\/iamwu555\/wp-content\/uploads\/sites\/5\/2021\/04\/20203241-8352527-768x126.jpg 768w, https:\/\/blog.save-web.org\/iamwu555\/wp-content\/uploads\/sites\/5\/2021\/04\/20203241-8352527-1536x252.jpg 1536w\" sizes=\"auto, (max-width: 1916px) 100vw, 1916px\" \/><\/p>\n<h2>\u4ee5\u56fe\u7247\u5f62\u5f0f\u5b58bing\u6bcf\u65e5\u4e00\u56fe<\/h2>\n<p>\u5728\u7f51\u4e0a\u770b\u4e86\u5f88\u591abing\u56fe\u7247\u7684api\uff0c\u5728\u7f51\u4e0a\u627e\u4e86\u4e00\u4e2a\u5f88\u826f\u5fc3\u7684\u7ad9\u957f\u7684\u56fe\u7247\u5f00\u59cb\u4e86\u6211\u7684\u722c\u866b\u4e4b\u8def<\/p>\n<pre><code>import requests\nfrom bs4 import BeautifulSoup\nimport os\n\ndef get_html(url):\n    headers = {'User-agent': 'Mozilla\/5.0 (Windows NT 6.3; WOW64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/55.0.2883.87 UBrowser\/6.2.3964.2 Safari\/537.36'}\n    r = requests.get(url, headers=headers)\n    return r.content\n\ndef download(text):\n    soup = BeautifulSoup(text, 'html.parser')\n    items = soup.find_all(\"img\")\n    path = \"E:bing\"\n    if os.path.exists(path) == False:\n        os.makedirs(path)\n    for item in items:\n        if item:\n            html = requests.get(item.get('src'))\n            img_name = path + str(item.get('src'))[24:41] +'.png'\n            with open(img_name, 'wb') as file:\n                file.write(html.content)\n                file.flush()\n            file.close()\n                \n\ndef main():\n    for i in range(1,124):\n        url = 'https:\/\/bing.ioliu.cn\/ranking?p={}'.format(i)\n        text = get_html(url)\n        download(text)\n        print(\"\u7b2c{}\u9875\u4e0b\u8f7d\u5b8c\u6210\".format(i))\n\nif __name__ == \"__main__\":\n    main()<\/code><\/pre>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u662f\u628a\u4ed6\u4ee5\u7167\u7247\u7684\u5f62\u5f0f\u4e0b\u8f7d\u4e0b\u6765\uff0c\u6211\u8f6c\u5ff5\u4e00\u60f3\uff0c\u6211\u8fd8\u8981\u5168\u90e8\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u4e00\u4e2a\u4e2a\u7684\u83b7\u53d6\u56fe\u7247\u7684url\uff0c\u592a\u8fc7\u4e8e\u590d\u6742\uff0c\u4e8e\u662f\u6211\u5c31\u2026\u2026<\/p>\n<h2>\u722c\u53d6\u6bcf\u5f20\u56fe\u7247\u7684url<\/h2>\n<pre><code>import requests\nfrom bs4 import BeautifulSoup\nimport os\n\ndef get_html(url):\n    headers = {'User-agent': 'Mozilla\/5.0 (Windows NT 6.3; WOW64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/55.0.2883.87 UBrowser\/6.2.3964.2 Safari\/537.36'}\n    r = requests.get(url, headers=headers)\n    return r.content\n\ndef download(text):\n    soup = BeautifulSoup(text, 'html.parser')\n    items = soup.find_all(\"img\")\n    for item in items:\n        if item:\n            img = str(item.get('src'))\n            img_url = img.strip('640x480.jpg?imageslim')\n            img_url += '1920x1080.jpg?imageslim'\n            f = open('imgurl.txt', 'a')\n            f.write(img_url + 'n')\n            f.close\n\n\n\ndef main():\n    for i in range(1,124):\n        url = 'https:\/\/bing.ioliu.cn\/ranking?p={}'.format(i)\n        text = get_html(url)\n        download(text)\n        print(\"\u7b2c{}\u9875\u4e0b\u8f7d\u5b8c\u6210\".format(i))\n\nif __name__ == \"__main__\":\n    main()<\/code><\/pre>\n<p>\u6211\u5c31\u628a\u4ed6\u6240\u6709\u7684\u56fe\u7247url\u7ed9\u5b58\u4e0b\u6765\u4e86\uff0c\u6ca1\u9519\u6587\u7ae0\u5934\u56fe\u5c31\u662f\u722c\u53d6\u540e\u7684\u7ed3\u679c\uff0c\u7136\u540e\u6b63\u5728\u6211\u611f\u53d7\u5230\u559c\u60a6\u7684\u540c\u65f6\uff0c\u6211\u7684ip\u88ab\u5c01\u4e86\uff0c\u4e0d\u8fc7\u8fd9\u4e9b\u56fe\u7247\u8fd8\u90fd\u53ef\u4ee5\u8bbf\u95ee\uff0c\u6ca1\u7b97\u767d\u5e72\u3002\u6280\u672f\u4e0d\u5230\u4f4d\uff0c\u8fd8\u6709\u5f85\u63d0\u5347!<\/p>\n<p>\u4e0d\u8fc7\u6700\u7ec8\u6211\u8fd8\u662f\u83b7\u5f97\u4e86\u6211\u60f3\u8981\u7684\u968f\u673aapi<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.wu555.ink\/random?wu=302\" \/><\/p>\n<p>1474\u5f20\u5462\uff0c\u591f\u6211\u73a9\u800d\u4e86\u3002<\/p>\n<p>http:\/\/www.wu555.ink\/random<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8ddd\u79bb403\u5df2\u7ecf\u8fc7\u53bb\u4e86\u4e24\u5c0f\u65f6\u5de6\u53f3\uff0c\u6211\u53c8\u53ef\u4ee5\u8bbf\u95ee\u4e86\uff01\uff01 \u672c\u7740\u505a\u4e00\u4e2a\u80fd\u8ba9\u535a\u5ba2\u80cc\u666f\u968f\u673a\u56fe\u7247\u7684api\u7684\u60f3\u6cd5\uff0c\u6211\u5f00\u59cb\u4e86\u4eba\u751f &hellip; <a href=\"https:\/\/blog.save-web.org\/iamwu555\/archives\/34\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;\u8bb0\u4e00\u6b21\u722c\u866b&#8221;<\/span><\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-34","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blog.save-web.org\/iamwu555\/wp-json\/wp\/v2\/posts\/34","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.save-web.org\/iamwu555\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.save-web.org\/iamwu555\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.save-web.org\/iamwu555\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.save-web.org\/iamwu555\/wp-json\/wp\/v2\/comments?post=34"}],"version-history":[{"count":3,"href":"https:\/\/blog.save-web.org\/iamwu555\/wp-json\/wp\/v2\/posts\/34\/revisions"}],"predecessor-version":[{"id":396,"href":"https:\/\/blog.save-web.org\/iamwu555\/wp-json\/wp\/v2\/posts\/34\/revisions\/396"}],"wp:attachment":[{"href":"https:\/\/blog.save-web.org\/iamwu555\/wp-json\/wp\/v2\/media?parent=34"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.save-web.org\/iamwu555\/wp-json\/wp\/v2\/categories?post=34"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.save-web.org\/iamwu555\/wp-json\/wp\/v2\/tags?post=34"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}