import requests from lxml import etree url="https://www.80142.com/txt/82776.html" html=requests.get(url) print(html)出现not get
时间: 2023-06-26 12:09:04 浏览: 98
您的代码有语法错误。正确的代码应该是:
```python
import requests
from lxml import etree
url = "https://www.80142.com/txt/82776.html"
html = requests.get(url)
print(html)
```
如果您仍然遇到 `not get` 错误,请检查您的网络连接或者网站是否可以正常访问。您可以尝试在浏览器中打开该网站,看看是否可以访问。
相关问题
import requests from lxml import etree url="https://www.80142.com/txt/82776.html" html=requests.get(url) print(html)出现requests not get
这个问题可能是因为您没有正确安装 requests 库。请尝试在命令行中使用以下命令安装 requests 库:
```
pip install requests
```
如果您已经安装了 requests 库,那么可能是因为您的代码中出现了其他问题。请检查您的代码是否正确导入了 requests 库,并且 URL 是否正确。另外,您的代码中缺少换行符,请注意格式。下面是您的代码的修改版:
```
import requests
from lxml import etree
url = "https://www.80142.com/txt/82776.html"
html = requests.get(url)
print(html)
```
import requests from lxml import etree url = "https://www.chzc.edu.cn/info/1355/80006.htm" web = requests.get(url) web.encoding = "utf-8" xp = etree.HTML(web.text) imgurls = xp.xpath('//*[@id="vsb_content_1011"]/p/img/@src') print(imgurls) realurls = [] for url in imgurls: realurls.append("https://www.chzc.edu.cn/"+url) print(realurls) for url in realurls: imgdata = requests.get(url) with open("c:\\"++".jpg","wb")as file: file.write(imgdata.content)报错原因
报错原因是因为代码中第10行的文件名拼接出现问题,文件名应该是字符串类型,而代码中缺少字符串连接符号。可以将该行代码修改为:
```
with open("c:\\" + "filename" + ".jpg", "wb") as file:
```
其中的 "filename" 可以替换为你想要的图片文件名。另外,还需要注意转义字符 "\" 需要使用双反斜杠 "\\" 表示。
阅读全文
相关推荐
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)