{"id":6835,"date":"2022-05-14T19:00:28","date_gmt":"2022-05-14T19:00:28","guid":{"rendered":"https:\/\/blog.gwlin.com\/?p=6835"},"modified":"2023-04-01T23:26:03","modified_gmt":"2023-04-01T15:26:03","slug":"selenium-chrome-webdriver-%e5%9c%a8-linux-%e4%b8%8b%e8%ae%be%e7%bd%ae%e8%af%ad%e8%a8%80","status":"publish","type":"post","link":"https:\/\/www.gwlin.com\/blog\/posts\/6835","title":{"rendered":"selenium chrome webdriver \u5728 linux \u4e0b\u8bbe\u7f6e\u8bed\u8a00"},"content":{"rendered":"\n<p>TLDR\uff1a<\/p>\n\n\n\n<p>\u5728\u542f\u52a8chromedriver\u7684\u65f6\u5019\u8bbe\u7f6e\u8bed\u8a00\u73af\u5883\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >export LANG=zh_CN.utf8\r\nexport LANGUAGE=zh_CN.utf8<\/code><\/pre>\n\n\n\n<p>\u6ce8\u610f\u8981\u5b89\u88c5\u5bf9\u5e94\u7684\u8bed\u8a00\uff0c\u5728ubuntu18.04\u7528 apt \u5b89\u88c5 language-pack-zh-hans\uff0c\u5176\u5b83\u7cfb\u7edf\u81ea\u5df1\u67e5\uff0c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" ># \u67e5\u770b\u5df2\u5b89\u88c5\u7684\u8bed\u8a00\r\nlocale -a\r\n# \u5b89\u88c5\u4e2d\u6587\r\napt install language-pack-zh-hans<\/code><\/pre>\n\n\n\n<p>===============<\/p>\n\n\n\n<p>\u8d77\u56e0\u662f\u8981\u7528selenium\u722c\u53d6\u4e00\u4e9b\u4e1c\u897f\uff0c\u5728\u672c\u5730\u6d4b\u8bd5\u6ca1\u95ee\u9898\uff0c\u4f46\u653e\u5230\u670d\u52a1\u5668\u8fd0\u884c\u540e\u53d1\u73b0\u722c\u53d6\u7684\u6570\u636e\u90fd\u662f\u82f1\u6587\u3002<\/p>\n\n\n\n<p>\u76f4\u89c9\u662f\u6d4f\u89c8\u5668\u53d1\u9001\u7684accept-language\u8bf7\u6c42\u5934\u5f15\u8d77\u7684\uff0c\u4e8e\u662f\u627e\u4e86\u4e00\u4e0bchrome\u7684\u542f\u52a8\u53c2\u6570\uff0c\u53ea\u6709\u4e00\u4e2a\u548c\u8bed\u8a00\u8bbe\u7f6e\u6709\u5173\uff1a--lang\u3002<\/p>\n\n\n\n<p>\u4e8e\u662f\u8bbe\u7f6e--lang=zh \u53c2\u6570\uff0c\u518d\u8fd0\u884c\u8fd8\u662f\u82f1\u6587\u3002\u5947\u602a\u7684\u662f\u5728\u672c\u5730 --lang \u662f\u751f\u6548\u7684\uff0c\u786e\u5b9e\u53ef\u4ee5\u5207\u6362\u8bed\u8a00\u3002\u672c\u5730\u548c\u670d\u52a1\u5668\u73af\u5883\u4e0d\u540c\u7684\u5730\u65b9\u5728\u4e8e\uff0c\u6211\u672c\u5730\u7684chrome\u662f\u8dd1\u5728windows\u4e0a\u7684\uff0c\u800c\u670d\u52a1\u5668\u662fUbuntu\u3002<\/p>\n\n\n\n<p>\u627e\u4e86\u4e00\u904d\u8c37\u6b4c\uff0c\u53d1\u73b0<a href=\"https:\/\/makandracards.com\/makandra\/502129-headless-chrome-changing-the-accept-language-header-is-not-possible\" target=\"_blank\" rel=\"noopener\">\u4e00\u7bc7\u6587\u7ae0<\/a>\u8bf4 --lang \u53c2\u6570\u5728 linux \u4e0b\u662f\u65e0\u6548\u7684\u3002WC\uff0c\u6d6a\u8d39\u534a\u5929\u65f6\u95f4\u3002<\/p>\n\n\n\n<p>\u4f46\u8f6c\u5934\u4e00\u60f3\uff0c\u4e0d\u53ef\u80fd\u5728ubuntu\u4e0b\u53ea\u80fd\u7528\u82f1\u6587\u7248\u7684chrome\u5427\uff0c\u80af\u5b9achrome\u8fd8\u901a\u8fc7\u5176\u5b83\u65b9\u5f0f\u6765\u8bc6\u522b\u5f53\u524d\u7684\u8bed\u8a00\u73af\u5883\u3002\u7136\u800c\u66f4\u6539\u7cfb\u7edf\u7684\u8bed\u8a00\u4ee3\u4ef7\u592a\u9ad8\uff0c\u4f46\u5982\u679c\u53ea\u662f\u66f4\u6539\u5f53\u524d\u7a0b\u5e8f\u7684\u73af\u5883\u53d8\u91cf\u5462\uff1f<\/p>\n\n\n\n<p>\u4ee3\u7801\u662f\u901a\u8fc7http\u548cchromedriver\u6c9f\u901a\uff0c\u5728\u8fd0\u884c\u4ee3\u7801\u7684\u65f6\u5019\u8bbe\u7f6e\u8bed\u8a00\u80af\u5b9a\u6ca1\u7528\uff0c\u90a3\u5c31\u5728\u8fd0\u884cchromedriver\u7684\u65f6\u5019\u8bbe\u7f6e\u8bed\u8a00\u8bd5\u8bd5\u3002<\/p>\n\n\n\n<p>Bammmmm\uff0c\u83b7\u53d6\u5230\u7684\u7ec8\u4e8e\u662f\u4e2d\u6587\u6570\u636e\u3002<\/p>\n\n\n\n<p>\u88ab\u8fd9\u4e2a\u95ee\u9898\u5361\u4e86\u5feb\u4e00\u4e2a\u661f\u671f\uff0c\u8fd9\u91cc\u8bb0\u4e00\u4e0b\uff0c\u5e2e\u52a9\u4e00\u4e0b\u9700\u8981\u7684\u670b\u53cb\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8d77\u56e0\u662f\u8981\u7528selenium\u722c\u53d6\u4e00\u4e9b\u4e1c\u897f\uff0c\u5728\u672c\u5730\u6d4b\u8bd5\u6ca1\u95ee\u9898\uff0c\u4f46\u653e\u5230\u670d\u52a1\u5668\u8fd0\u884c\u540e\u53d1\u73b0\u722c\u53d6\u7684\u6570\u636e\u90fd\u662f\u82f1\u6587\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[179],"tags":[],"class_list":["post-6835","post","type-post","status-publish","format-standard","hentry","category-notes"],"_links":{"self":[{"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/posts\/6835","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/comments?post=6835"}],"version-history":[{"count":1,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/posts\/6835\/revisions"}],"predecessor-version":[{"id":42911,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/posts\/6835\/revisions\/42911"}],"wp:attachment":[{"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/media?parent=6835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/categories?post=6835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/tags?post=6835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}