{"id":5935,"date":"2025-06-10T13:42:58","date_gmt":"2025-06-10T05:42:58","guid":{"rendered":"https:\/\/benson80.eu.org\/?p=5935"},"modified":"2025-06-10T13:55:59","modified_gmt":"2025-06-10T05:55:59","slug":"%e7%94%a8-node-js-%e6%90%ad%e5%bb%ba%e8%b7%a8%e5%9f%9f%e4%bb%a3%e7%90%86%ef%bc%8c%e8%8e%b7%e5%8f%96-bing-%e6%af%8f%e6%97%a5%e4%b8%80%e5%9b%be","status":"publish","type":"post","link":"https:\/\/benson80.eu.org\/?p=5935","title":{"rendered":"\u7528 Node.js \u642d\u5efa\u8de8\u57df\u4ee3\u7406\uff0c\u83b7\u53d6 Bing \u6bcf\u65e5\u4e00\u56fe"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\ud83d\udccc \u76ee\u6807<\/h2>\n\n\n\n<p>\u5b9e\u73b0\u7f51\u9875 HTML \u80fd\u8de8\u57df\u8bf7\u6c42 Bing \u6bcf\u65e5\u4e00\u56fe\uff0c\u901a\u8fc7\u4ee3\u7406\u670d\u52a1 <code>http:\/\/sunxiao.dpdns.org:8080\/<\/code> \u83b7\u53d6\u56fe\u7247\u6570\u636e\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 \u6b65\u9aa4\u4e00\uff1a\u5b89\u88c5 Node.js \u548c npm<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt update\napt install -y nodejs npm<\/code>\n\u786e\u8ba4\u7248\u672c\uff1a\n<code>node -v\nnpm -v\n<\/code>\u5efa\u8bae Node.js \u7248\u672c \u2265 14<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 \u6b65\u9aa4\u4e8c\uff1a\u514b\u9686\u5e76\u5b89\u88c5 CORS Anywhere<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>git clone https:\/\/github.com\/Rob--W\/cors-anywhere.git<br>cd cors-anywhere<br>npm install<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 \u6b65\u9aa4\u4e09\uff1a\u4f7f\u7528 <code>screen<\/code> \u542f\u52a8\u540e\u53f0\u670d\u52a1<\/h2>\n\n\n\n<p>1. \u542f\u52a8\u4e00\u4e2a\u65b0\u7684 <code>screen<\/code> \u4f1a\u8bdd\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><\/ol>\n\n\n\n<p><code>screen -S corsproxy<\/code><\/p>\n\n\n\n<p>2. \u5728 <code>screen<\/code> \u4f1a\u8bdd\u4e2d\u542f\u52a8\u670d\u52a1\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><\/ol>\n\n\n\n<p><code>node server.js --hostname 0.0.0.0 --port 8080<\/code><\/p>\n\n\n\n<p>\u542f\u52a8\u540e\u5e94\u770b\u5230\uff1a<\/p>\n\n\n\n<p><code>Running CORS Anywhere on 0.0.0.0:8080<\/code><\/p>\n\n\n\n<p>3. \u4f7f\u7528\u5feb\u6377\u952e\u9000\u51fa screen \u4f1a\u8bdd\u4f46\u4e0d\u5173\u95ed\u7a0b\u5e8f\uff1a<ul><li>\u6309\u4e0b\uff1a<code>Ctrl + A<\/code> \u7136\u540e <code>D<\/code><\/li><\/ul>\u8fd9\u4f1a\u5c06\u4f60\u4ece screen \u4e2d\u5206\u79bb\uff0c\u670d\u52a1\u4ecd\u5728\u540e\u53f0\u8fd0\u884c\u3002<\/p>\n\n\n\n<p>4. \u67e5\u770b\u662f\u5426\u4ecd\u5728\u8fd0\u884c\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><\/ol>\n\n\n\n<p><code>screen -ls<\/code><\/p>\n\n\n\n<p>\u6062\u590d screen \u4f1a\u8bdd\uff1a<\/p>\n\n\n\n<p><code>screen -r corsproxy<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 \u6b65\u9aa4\u56db\uff1a\u914d\u7f6e\u9632\u706b\u5899\u6216 GCP \u9632\u706b\u5899\uff08\u5982\u90e8\u7f72\u5728\u4e91\u7aef\uff09<\/h2>\n\n\n\n<p>\u786e\u4fdd\u9632\u706b\u5899\u6216\u4e91\u5e73\u53f0\uff08\u5982 GCP\u3001AWS\u3001\u963f\u91cc\u4e91\uff09\u5141\u8bb8 <code>TCP 8080<\/code> \u7aef\u53e3\u5165\u7ad9\u8bbf\u95ee\u3002<\/p>\n\n\n\n<p>\u5728 GCP \u4e0a\uff0c\u4f60\u9700\u8981\u5728\u201c<strong>VPC \u7f51\u7edc \u2192 \u9632\u706b\u5899\u89c4\u5219<\/strong>\u201d\u4e2d\u6dfb\u52a0\u4e00\u6761\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u534f\u8bae\uff1aTCP:8080<\/li>\n\n\n\n<li>\u6e90 IP\uff1a<code>0.0.0.0\/0<\/code><\/li>\n\n\n\n<li>\u76ee\u6807\uff1a\u4f60\u7684\u5b9e\u4f8b<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 \u6b65\u9aa4\u4e94\uff1a\u524d\u7aef HTML \u9875\u9762\u793a\u4f8b<\/h2>\n\n\n\n<p>\u5c06\u4ee5\u4e0b\u4ee3\u7801\u4fdd\u5b58\u4e3a <code>index.html<\/code>\uff0c\u653e\u5728\u4efb\u610f Web \u670d\u52a1\u5668\u4e0a\u8fd0\u884c\u5373\u53ef\uff08\u5982 nginx\u3001Apache \u6216\u672c\u5730\u6d4b\u8bd5\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;!DOCTYPE html><br>&lt;html lang=\"en\"><br>&lt;head><br>    &lt;meta charset=\"UTF-8\"><br>    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><br>    &lt;title>Microsoft Bing \u6bcf\u65e5\u4e00\u56fe&lt;\/title><br>    &lt;style><br>        body {<br>            margin: 0;<br>            padding: 0;<br>            display: flex;<br>            align-items: center;<br>            justify-content: center;<br>            height: 100vh;<br>            background-color: #000;<br>        }<br><br>        #bingImage {<br>            max-width: 100%;<br>            max-height: 100%;<br>        }<br>    &lt;\/style><br>&lt;\/head><br>&lt;body><br><br>    &lt;img id=\"bingImage\" alt=\"Bing Daily Image\" \/><br><br>    &lt;script><br>        \/\/ \u4f7f\u7528CORS Anywhere\u4ee3\u7406\u83b7\u53d6\u6bcf\u65e5\u4e00\u56fe\u4fe1\u606f<br>        async function getBingWallpaper() {<br>            try {<br>                const proxyUrl = 'http:\/\/sunxiao.dpdns.org:8080\/';<br>                const apiUrl = 'https:\/\/www.bing.com\/HPImageArchive.aspx?format=js&amp;idx=0&amp;n=1&amp;mkt=en-US';<br>                const response = await fetch(proxyUrl + apiUrl);<br>                const data = await response.json();<br>                <br>                \/\/ \u8f93\u51fa\u56fe\u50cfURL\u503c<br>                console.log('Image URL:', data.images[0].url);<br><br>                const imageUrl = 'https:\/\/www.bing.com' + data.images[0].url;<br>                <br>                \/\/ \u8bbe\u7f6e\u56fe\u7247\u6e90<br>                document.getElementById('bingImage').src = imageUrl;<br>            } catch (error) {<br>                console.error('Error fetching Bing wallpaper:', error);<br>            }<br>        }<br><br>        \/\/ \u9875\u9762\u52a0\u8f7d\u65f6\u8c03\u7528\u83b7\u53d6Bing\u6bcf\u65e5\u4e00\u56fe\u7684\u51fd\u6570<br>        window.onload = getBingWallpaper;<br>    &lt;\/script><br><br>&lt;\/body><br>&lt;\/html><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 \u8865\u5145\u8bf4\u660e\uff1a\u91cd\u542f\u540e\u670d\u52a1\u4e22\u5931\u600e\u4e48\u529e\uff1f<\/h2>\n\n\n\n<p>screen \u4f1a\u8bdd\u4e0d\u4f1a\u81ea\u52a8\u91cd\u542f\uff0c\u82e5\u7cfb\u7edf\u91cd\u542f\u540e\u4f60\u9700\u8981\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>screen -S corsproxy<br>cd cors-anywhere<br>node server.js --hostname 0.0.0.0 --port 8080<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u4f60\u5e0c\u671b\u81ea\u52a8\u542f\u52a8\uff0c\u53ef\u4ee5\u5c06\u5176\u52a0\u5165\u5f00\u673a\u811a\u672c\u6216\u4f7f\u7528\u66f4\u5f3a\u5927\u7684 <code>pm2<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83c\udf89 \u6210\u529f\u6548\u679c<\/h2>\n\n\n\n<p>\u8bbf\u95ee <code>index.html<\/code> \u540e\uff0c\u4f60\u5c06\u770b\u5230\u6765\u81ea Bing \u6bcf\u65e5\u4e00\u56fe\u7684\u9ad8\u6e05\u80cc\u666f\u56fe\u81ea\u52a8\u663e\u793a\u5728\u7f51\u9875\u4e2d\u592e\u3002<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ud83d\udccc \u76ee\u6807 \u5b9e\u73b0\u7f51\u9875 HTML \u80fd\u8de8\u57df\u8bf7\u6c42 Bing &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,6],"tags":[],"class_list":["post-5935","post","type-post","status-publish","format-standard","hentry","category-html","category-linux"],"_links":{"self":[{"href":"https:\/\/benson80.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/5935","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/benson80.eu.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/benson80.eu.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/benson80.eu.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/benson80.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5935"}],"version-history":[{"count":15,"href":"https:\/\/benson80.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/5935\/revisions"}],"predecessor-version":[{"id":5950,"href":"https:\/\/benson80.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/5935\/revisions\/5950"}],"wp:attachment":[{"href":"https:\/\/benson80.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/benson80.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/benson80.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}