{"id":6756,"date":"2023-03-07T19:47:36","date_gmt":"2023-03-07T11:47:36","guid":{"rendered":"https:\/\/tommykwan.com\/blog\/?p=6756"},"modified":"2023-03-07T19:47:36","modified_gmt":"2023-03-07T11:47:36","slug":"python-%e7%88%ac%e8%9f%b2-capture-html-code-%e5%8f%96%e5%be%97%e7%b6%b2%e9%a0%81html-code","status":"publish","type":"post","link":"https:\/\/tommykwan.com\/blog\/it\/python-%e7%88%ac%e8%9f%b2-capture-html-code-%e5%8f%96%e5%be%97%e7%b6%b2%e9%a0%81html-code\/","title":{"rendered":"Python \u722c\u87f2 : Capture HTML CODE \u53d6\u5f97\u7db2\u9801HTML Code"},"content":{"rendered":"<p>Ref: <a href=\"https:\/\/www.guru99.com\/accessing-internet-data-with-python.html\">https:\/\/www.guru99.com\/accessing-internet-data-with-python.html<\/a><\/p>\n<h1 class=\"entry-title\">Python Internet Access using Urllib.Request and urlopen()<\/h1>\n<p><strong>Python 3 Example<\/strong><\/p>\n<pre>#\r\n# read the data from the URL and print it\r\n#\r\nimport urllib.request\r\n# open a connection to a URL using urllib\r\nwebUrl  = urllib.request.urlopen('https:\/\/www.youtube.com\/user\/guru99com')\r\n\r\n#get the result code and print it\r\nprint (\"result code: \" + str(webUrl.getcode()))\r\n\r\n# read the data from the URL and print it\r\ndata = webUrl.read()\r\nprint (data)<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ref: https:\/\/www.guru99.com\/accessing-internet-data-with-python.html Python Internet Access using Urllib.Request and urlopen() Python 3 Example # # read the data from the URL and print it # import urllib.request # open a connection to a URL using urllib webUrl = urllib.request.urlopen(&#8216;https:\/\/www.youtube.com\/user\/guru99com&#8217;) #get the result code and print it print (&#8220;result code: &#8221; + str(webUrl.getcode())) # read the data<a class=\"read-more \" href=\"https:\/\/tommykwan.com\/blog\/it\/python-%e7%88%ac%e8%9f%b2-capture-html-code-%e5%8f%96%e5%be%97%e7%b6%b2%e9%a0%81html-code\/\" title=\"Read More\"> <span class=\"button default\">Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27,28],"tags":[],"class_list":["post-6756","post","type-post","status-publish","format-standard","hentry","category-it","category-python"],"_links":{"self":[{"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/posts\/6756","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/comments?post=6756"}],"version-history":[{"count":1,"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/posts\/6756\/revisions"}],"predecessor-version":[{"id":6757,"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/posts\/6756\/revisions\/6757"}],"wp:attachment":[{"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/media?parent=6756"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/categories?post=6756"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/tags?post=6756"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}