Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 关于使用GET请求和Beautiful Soup进行web抓取的问题_Python 3.x_Web Scraping_Beautifulsoup - Fatal编程技术网

Python 3.x 关于使用GET请求和Beautiful Soup进行web抓取的问题

Python 3.x 关于使用GET请求和Beautiful Soup进行web抓取的问题,python-3.x,web-scraping,beautifulsoup,Python 3.x,Web Scraping,Beautifulsoup,我正在尝试使用BeautifulSoup来获取URL 下面是我的代码: url= 'https://www.clinicspots.com/what-is-the-knee-replacement-surgery-cost-in-india' response = requests.get(url) s4 = BeautifulSoup(response.content, 'html.parser') s4 此外,我需要执行s4.title.text 这给了我一些奇怪的输出(似乎是用中文写的

我正在尝试使用
BeautifulSoup
来获取URL

下面是我的代码:

url= 'https://www.clinicspots.com/what-is-the-knee-replacement-surgery-cost-in-india'
response = requests.get(url)

s4 = BeautifulSoup(response.content, 'html.parser')
s4
此外,我需要执行
s4.title.text

这给了我一些奇怪的输出(似乎是用中文写的)

我试着手动打开URL,这似乎工作正常

我不知道如何解决这个问题。请建议

编辑#1:以下是输出的屏幕截图:


使用
s4=beautifulsop(response.text,'html.parser')
而不是
s4=beautifulsop(response.content,'html.parser')
使用
s4=beautifulsop(response.text,'html.parser')
你可以试试:

headers =  {'User-Agent': 'Mozilla/5.0 (Windows NT x.y; Win64; x64; rv:10.0) Gecko/20100101 Firefox/10.0 '}  

url= 'https://www.clinicspots.com/what-is-the-knee-replacement-surgery-cost-in-india'
response = requests.get(url, headers=headers)
s4 = BeautifulSoup(response.text, 'lxml')
print(s4)
你可以试试:

headers =  {'User-Agent': 'Mozilla/5.0 (Windows NT x.y; Win64; x64; rv:10.0) Gecko/20100101 Firefox/10.0 '}  

url= 'https://www.clinicspots.com/what-is-the-knee-replacement-surgery-cost-in-india'
response = requests.get(url, headers=headers)
s4 = BeautifulSoup(response.text, 'lxml')
print(s4)

它给了你什么?你得给我们看看!否则我们就不是翻译公司了。你的问题和编程语言有关吗?它给了你什么?你得给我们看看!否则我们就不是翻译公司了。您的问题与编程语言有关吗?