为什么当我运行代码时我没有得到我正在抓取的网页的信息?

时间:2020-04-22 23:00:33

标签: python beautifulsoup

我刚刚开始抓取网络并正在学习教程,当我按照视频运行下面的代码时,我应该看到网页的标题,但是当我在vstudio中运行它时,没有任何信息网站弹出,而当他运行自己的代码(看起来像在某种形式的外壳中时)时,将显示页面标题。原谅我我是菜鸟

import bs4
#uReq is our arbitrary shorthand for urllib.request
import urllib
from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup

#The URL we plan to use
my_url = 'https://www.newegg.com/'

#uReq(my_url) opens up web client
Client = uReq(my_url)
#uClient.read dumps everything out of the url
html_page = Client.read()
Client.close()

#Putting our html page into beautifulsoup from bs4
#html parser
page_soup = soup(html_page, "html.parser")
page_soup.h1

0 个答案:

没有答案
相关问题