首页 > 解决方案 > 为什么当我运行我的代码时,我没有得到关于我正在抓取的网页的信息?

问题描述

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

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

标签: pythonbeautifulsoup

解决方案


推荐阅读