歡迎您光臨本站 註冊首頁

python如何查看網頁代碼

←手機掃碼閱讀     f2h0b53ohn @ 2020-06-10 , reply:0

用python查看網頁代碼的方法:

1、使用“import”導入requests包

  import requests

 

2、使用requests包的get()函數通過網頁鏈接獲取網頁的源碼,然後使用print()語句輸出就可以了

執行結果如下:

實例擴展:

Python獲取網頁html代碼

獲取網頁html代碼:

  import requests  res = requests.get('https://www.jb51.net/更換成你的網頁.html')  res.encoding = 'utf-8'  print(res.text)

 

運行結果:

                       

   


[f2h0b53ohn ] python如何查看網頁代碼已經有221次圍觀

http://coctec.com/docs/python/shhow-post-237932.html