我无法使用python中的web爬虫提取标记体
这是我用python编写的代码。我可以提取href标签,但不能提取身体内部的内容。我是否应该使用get()命令或“content”或其他命令来显示“body”我无法使用python中的web爬虫提取标记体,python,beautifulsoup,web-crawler,Python,Beautifulsoup,Web Crawler,这是我用python编写的代码。我可以提取href标签,但不能提取身体内部的内容。我是否应该使用get()命令或“content”或其他命令来显示“body” import requests from bs4 import BeautifulSoup def web(): url='https://www.phoenixmarketcity.com/mumbai/brands' source = requests.get(url) plain=source.text
import requests
from bs4 import BeautifulSoup
def web():
url='https://www.phoenixmarketcity.com/mumbai/brands'
source = requests.get(url)
plain=source.text
soup = BeautifulSoup(plain,"html.parser")
for link in soup.findAll('a'):
href = link.get('body')
print(href)
web()
我想这是你想要做的:-
from bs4 import BeautifulSoup
import requests
def web():
url='https://www.phoenixmarketcity.com/mumbai/brands'
source = requests.get(url)
plain=source.text
soup = BeautifulSoup(plain,"html.parser")
tags = soup('a')
for link in tags:
href = link.get('href')
print(href)
web()
link.getText()