{"id":3538,"date":"2025-04-14T16:57:09","date_gmt":"2025-04-14T07:57:09","guid":{"rendered":"https:\/\/www.dogrow.net\/python\/?p=3538"},"modified":"2025-05-25T09:55:52","modified_gmt":"2025-05-25T00:55:52","slug":"blog126-%e4%bb%ae%e6%83%b3%e3%83%9e%e3%82%b7%e3%83%b3%e4%b8%8a%e3%81%ae%e3%83%98%e3%83%83%e3%83%89%e3%83%ac%e3%82%b9ubuntu22%e3%81%a7selenium%e3%82%92%e5%8b%95%e3%81%8b%e3%81%99%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/python\/blog126-%e4%bb%ae%e6%83%b3%e3%83%9e%e3%82%b7%e3%83%b3%e4%b8%8a%e3%81%ae%e3%83%98%e3%83%83%e3%83%89%e3%83%ac%e3%82%b9ubuntu22%e3%81%a7selenium%e3%82%92%e5%8b%95%e3%81%8b%e3%81%99%e3%80%82\/","title":{"rendered":"(126) Hyper-V\u4eee\u60f3\u30de\u30b7\u30f3\u4e0a\u306e\u30d8\u30c3\u30c9\u30ec\u30b9Ubuntu22\u3067Selenium\u3092\u52d5\u304b\u3059\u3002"},"content":{"rendered":"<h1 class=\"my_h\">1. \u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>Windows11\u306e Hyper-V\u4e0a\u3067 Ubuntu22\u4eee\u60f3\u30de\u30b7\u30f3\u3092\u52d5\u304b\u3057\u3066\u3044\u308b\u3002<br \/>\n\u666e\u6bb5\u306f Windows11\u304b\u3089 Putty\u3067 ssh\u63a5\u7d9a\u3057\u3001CUI\u3067\u64cd\u4f5c\u3057\u3066\u3044\u308b\u3002<\/p>\n<p>\u3053\u306e\u74b0\u5883\u3067 Python + Selenium\u3092\u4f7f\u3063\u3066 Web\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u3092\u5b9f\u884c\u3057\u305f\u3044\u3002<\/p>\n<h1 class=\"my_h\">2. \u3084\u3063\u3066\u307f\u308b<\/h1>\n<h2 class=\"my_h\">1) Web Browser\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002<\/h2>\n<p>Web\u30d6\u30e9\u30a6\u30b6\u306b\u306f Google Chrome\u3092\u4f7f\u7528\u3059\u308b\u3002<\/p>\n<pre class=\"my_pre_bgBlack\">\r\n$ <span class='my_fc_yellow'>wget https:\/\/dl.google.com\/linux\/direct\/google-chrome-stable_current_amd64.deb<\/span>\r\n$ <span class='my_fc_yellow'>sudo apt install .\/google-chrome-stable_current_amd64.deb -y<\/span>\r\n<\/pre>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u305f\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u3002<\/p>\n<pre class=\"my_pre_bgBlack\">\r\n$ <span class='my_fc_yellow'>google-chrome --version<\/span>\r\nGoogle Chrome 135.0.7049.84\r\n<\/pre>\n<h2 class=\"my_h\">2) Web Driver\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002<\/h2>\n<p>Web\u30c9\u30e9\u30a4\u30d0\u3068\u306f\u3001Web\u30d6\u30e9\u30a6\u30b6\u3068\u5916\u90e8\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u63a5\u7d9a\u3059\u308b\u305f\u3081\u306e\u4ef2\u4ecb\u30d7\u30ed\u30b0\u30e9\u30e0\u3060\u3002<br \/>\n\u4eca\u56de\u306f Web\u30d6\u30e9\u30a6\u30b6\u306b Google Chrome\u3092\u4f7f\u3046\u306e\u3067\u3001\u3053\u308c\u306b\u5bfe\u5fdc\u3057\u305f Google\u793e\u88fd\u306e Web\u30c9\u30e9\u30a4\u30d0\u3092\u4f7f\u3046\u3002<\/p>\n<p>\u4e0a\u3067 Chrome\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u78ba\u8a8d\u3057\u3001\u4e0b\u8a18\u30b5\u30a4\u30c8\u3067\u3053\u308c\u306b\u5bfe\u5fdc\u3059\u308b Web\u30c9\u30e9\u30a4\u30d0\u3092\u9078\u629e\u3059\u308b\u3002<br \/>\n<a href=\"https:\/\/googlechromelabs.github.io\/chrome-for-testing\/\" target=\"_blank\">https:\/\/googlechromelabs.github.io\/chrome-for-testing\/<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.dogrow.net\/python\/wp-content\/uploads\/2025\/04\/Image1.jpg\" alt=\"\" class=\"my_add_bs1\" \/><\/a><\/p>\n<p>\u4eca\u56de\u306f\u3001Version: 135.0.7049.84 chromedriver linux64\u7528\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002<\/p>\n<pre class=\"my_pre_bgBlack\">\r\n$ <span class='my_fc_yellow'>wget https:\/\/storage.googleapis.com\/chrome-for-testing-public\/135.0.7049.84\/linux64\/chromedriver-linux64.zip<\/span>\r\n$ <span class='my_fc_yellow'>unzip chromedriver_linux64.zip<\/span>\r\n<\/pre>\n<p>\u3053\u3061\u3089\u3082\u5ff5\u306e\u305f\u3081\u306b\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u78ba\u8a8d\u3057\u3066\u304a\u304f\u3002<\/p>\n<pre class=\"my_pre_bgBlack\">\r\n$ <span class='my_fc_yellow'>.\/chromedriver-linux64\/chromedriver --version<\/span>\r\nChromeDriver 135.0.7049.84 (6c019e56001911b3fd467e03bf68c435924d62f4-refs\/branch-heads\/7049@{#1778})\r\n<\/pre>\n<h2 class=\"my_h\">3) Python Selenium\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002<\/h2>\n<pre class=\"my_pre_bgBlack\">\r\n$ <span class='my_fc_yellow'>pip install selenium<\/span>\r\n<\/pre>\n<h2 class=\"my_h\">4) Python + Selenium\u3067 Web\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u3057\u3066\u307f\u308b\uff01<\/h2>\n<p>Python\u3092\u8d77\u52d5\u3059\u308b\u3002<\/p>\n<pre class=\"my_pre_bgBlack\">\r\n$ <span class='my_fc_yellow'>python<\/span>\r\n<\/pre>\n<p>Python\u30b7\u30a7\u30eb\u3067\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3059\u308b\u3002<br \/>\n<pre class=\"my_pre_python\">\nfrom selenium import webdriver\nfrom selenium.webdriver.chrome.service import Service\nfrom selenium.webdriver.common.by import By<\/p>\n<p><span class=\"my_fc_green\"># Headless Chrome\u7528\u30aa\u30d7\u30b7\u30e7\u30f3<\/span>\noptions = webdriver.ChromeOptions()\noptions.add_argument(<span class=\"my_fc_red\">&#8220;&#8211;headless=new&#8221;<\/span>)  <span class=\"my_fc_green\"># Chrome 109\u4ee5\u964d\u3067\u63a8\u5968<\/span>\noptions.add_argument(<span class=\"my_fc_red\">&#8220;&#8211;no-sandbox&#8221;<\/span>)\noptions.add_argument(<span class=\"my_fc_red\">&#8220;&#8211;disable-dev-shm-usage&#8221;<\/span>)<\/p>\n<p><span class=\"my_fc_green\"># Web\u30c9\u30e9\u30a4\u30d0\u30fc\u30b5\u30fc\u30d3\u30b9<\/span>\nservice = Service(<span class=\"my_fc_red\">&#8220;.\/chromedriver-linux64\/chromedriver&#8221;<\/span>)\ndriver = webdriver.Chrome(service=service, options=options)<\/p>\n<p><span class=\"my_fc_green\"># \u6c17\u8c61\u5e81\u306e\u30d8\u30c3\u30c9\u30e9\u30a4\u30f3\u3092\u53d6\u5f97\u3059\u308b\u3002<\/span>\ndriver.get(<span class=\"my_fc_red\">&#8220;https:\/\/www.jma.go.jp\/jma\/index.html&#8221;<\/span>)\ntime.sleep(5)\ndiv_news = driver.find_element(By.ID, <span class=\"my_fc_red\">&#8220;news&#8221;<\/span>)\nheadlines = div_news.find_elements(By.TAG_NAME, <span class=\"my_fc_red\">&#8220;a&#8221;<\/span>)\nfor title in headlines :\n    print(title.text)\n<\/pre><\/p>\n<p>\u3067\u304d\u305f\u3002<\/p>\n<pre class=\"my_pre_bgBlack\">\r\n\u3072\u307e\u308f\u308a\uff19\u53f7\u306e\u4fdd\u5b88\u4f5c\u696d\u306b\u4f34\u3046\u89b3\u6e2c\u4f11\u6b62\u306e\u4e88\u5b9a\u306b\u3064\u3044\u3066\r\n\u4ee4\u548c\uff17\u5e74\uff13\u6708\u306e\u5730\u9707\u6d3b\u52d5\u53ca\u3073\u706b\u5c71\u6d3b\u52d5\u306b\u3064\u3044\u3066\r\n\u5357\u6d77\u30c8\u30e9\u30d5\u5730\u9707\u95a2\u9023\u89e3\u8aac\u60c5\u5831\u306b\u3064\u3044\u3066 \uff0d\u6700\u8fd1\u306e\u5357\u6d77\u30c8\u30e9\u30d5\u5468\u8fba\u306e\u5730\u6bbb\u6d3b\u52d5\uff0d\r\n\u9727\u5cf6\u5c71\uff08\u65b0\u71c3\u5cb3\uff09\u306e\u8b66\u6212\u304c\u5fc5\u8981\u306a\u7bc4\u56f2\u3092\u6982\u306d\uff13km\u306b\u7e2e\u5c0f\r\n\u9727\u5cf6\u5c71\uff08\u65b0\u71c3\u5cb3\uff09\u306e\u5674\u706b\u8b66\u6212\u30ec\u30d9\u30eb\u3092\uff13\u3078\u5f15\u4e0a\u3052\r\n\u7279\u6b8a\u5207\u624b\u300c\u6c17\u8c61\u696d\u52d9150\u5468\u5e74\u300d\u304c\u4ee4\u548c\uff17\u5e74\uff15\u670828\u65e5\u306b\u767a\u884c\u3055\u308c\u307e\u3059\u3002\r\n\u77f3\u57a3\u5cf6\u306e\u65e5\u6700\u9ad8\u6c17\u6e29\u53ca\u3073\u65e5\u6700\u4f4e\u6c17\u6e29\u306e\u904e\u53bb\u30c7\u30fc\u30bf\u306b\u3064\u3044\u3066\r\n<\/pre>\n<hr class=\"my_hr_bottom\">\n","protected":false},"excerpt":{"rendered":"<p>1. \u3084\u308a\u305f\u3044\u3053\u3068 Windows11\u306e Hyper-V\u4e0a\u3067 Ubuntu22\u4eee\u60f3\u30de\u30b7\u30f3\u3092\u52d5\u304b\u3057\u3066\u3044\u308b\u3002 \u666e\u6bb5\u306f Windows11\u304b\u3089 Putty\u3067 ssh\u63a5\u7d9a\u3057\u3001CUI\u3067\u64cd\u4f5c\u3057\u3066\u3044\u308b\u3002 \u3053\u306e\u74b0\u5883\u3067 Python + \u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/python\/blog126-%e4%bb%ae%e6%83%b3%e3%83%9e%e3%82%b7%e3%83%b3%e4%b8%8a%e3%81%ae%e3%83%98%e3%83%83%e3%83%89%e3%83%ac%e3%82%b9ubuntu22%e3%81%a7selenium%e3%82%92%e5%8b%95%e3%81%8b%e3%81%99%e3%80%82\/\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30,62],"tags":[],"class_list":["post-3538","post","type-post","status-publish","format-standard","hentry","category-beautifulsoup","category-selenium"],"views":718,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/3538","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/comments?post=3538"}],"version-history":[{"count":13,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/3538\/revisions"}],"predecessor-version":[{"id":3767,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/3538\/revisions\/3767"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/media?parent=3538"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/categories?post=3538"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/tags?post=3538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}