python - 为什么当我运行我的代码时,我没有得到关于我正在抓取的网页的信息?
问题描述
我刚刚开始进行网络抓取并正在学习教程,当我按照视频运行下面的代码时,我应该会看到网页的标题,但是当我在 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
解决方案
推荐阅读
- .net - 从目录加载文件并添加到组合框
- reactjs - 是否可以为 React Native 中的动画分配一个值(id)?
- php - 如何将一个巨大的数组分成块?
- c# - 从全名中删除中间名,并以大写字母开头
- asp.net - 如何取消对文本框数据的任何更改
- netsuite - 是否有强制在 Netsuite 中打开/保存的自动化方法
- questasim - 设置 Questa Sim 双击编辑器
- delphi - 运行时粗体 ListView 项目在 Delphi Tokyo 中不起作用
- regex - Asp.net DataAnnotations Regex 根据之前的 Char 评估 Char
- javascript - 在 google maps JS API 中的数据功能点击事件上捕获修饰键(control/ctrl、shift、alt)