Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.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 使用Beauty Soup从HTML标记内部提取数据_Python_Html_Beautifulsoup - Fatal编程技术网

Python 使用Beauty Soup从HTML标记内部提取数据

Python 使用Beauty Soup从HTML标记内部提取数据,python,html,beautifulsoup,Python,Html,Beautifulsoup,我试图用BeautifulSoup从下面的HTML代码中获取信息 我正在试图获取d=中的信息 我试着用 for node in soup.findAll('d'): print(''.join(node.findAll(text=True))) 但是,它没有返回任何信息 任何帮助都将不胜感激 <path fill="none" stroke="#F39C13" stroke-width="3" d="M70,398L80.91495058333334,398L80.9149505

我试图用BeautifulSoup从下面的HTML代码中获取信息

我正在试图获取
d=
中的信息

我试着用

for node in soup.findAll('d'):
    print(''.join(node.findAll(text=True)))
但是,它没有返回任何信息

任何帮助都将不胜感激

<path fill="none" stroke="#F39C13" stroke-width="3" d="M70,398L80.91495058333334,398L80.91495058333334,393.12462491393086L139.9525775,393.12462491393086L139.9525775,390.3995549380779L171.26091083333333,390.3995549380779L171.26091083333333,375.6214167892933L191.91833333333335,375.6214167892933L191.91833333333335,370.57940817475315L192.15775,370.57940817475315L192.15775,346.8216070234775L192.52608333333333,346.8216070234775L192.52608333333333,316.5126268923282L193.31799999999998,316.5126268923282L193.31799999999998,311.17636059522624L195.11049416666665,311.17636059522624L195.11049416666665,294.184572994709L250.7719225,294.184572994709L250.7719225,289.64175873696803L251.5575775,289.64175873696803L251.5575775,284.19552891552445L278.176475,284.19552891552445L278.176475,274.12735109627243L317.6176083333333,274.12735109627243L317.6176083333333,267.6450061351061L361.59108333333336,267.6450061351061L361.59108333333336,261.7097197920084L376.50305833333334,261.7097197920084L376.50305833333334,257.4876501142978L398.179475,257.4876501142978L398.179475,253.6807437062263L413.20010833333333,253.6807437062263L413.20010833333333,244.68390284180637L415.8889416666667,244.68390284180637L415.8889416666667,232.59131014943122L433.19508333333334,232.59131014943122L433.19508333333334,217.11191560626028L462.73541666666665,217.11191560626028L462.73541666666665,212.86778950989245L537.1074416666668,212.86778950989245L537.1074416666668,181.49502268135544L572.4932249999999,181.49502268135544L572.4932249999999,153.38834724724293L579.8101666666666,153.38834724724293L579.8101666666666,147.33719431459903L585.7403333333334,147.33719431459903L585.7403333333334,132.7568776518106L628.0489416666667,132.7568776518106L628.0489416666667,127.66153735816481L632.008525,127.66153735816481L632.008525,120.59249015748499L637.743475,120.59249015748499L637.743475,112.57549162805078L680.1441666666666,112.57549162805078L680.1441666666666,107.87408149242401L696.3931916666667,107.87408149242401L696.3931916666667,104.2686095237732L704.7727749999999,104.2686095237732L704.7727749999999,102.36035726070402L733,102.36035726070402L733,102.36035726070402"></path>

以下内容如何

从bs4导入美化组
html=“”“”“
soup=BeautifulSoup(html,features=“lxml”)
element=soup.select('路径:第n个子(1)')[0]['d']
打印(元素)
以下内容如何

从bs4导入美化组
html=“”“”“
soup=BeautifulSoup(html,features=“lxml”)
element=soup.select('路径:第n个子(1)')[0]['d']
打印(元素)
Try
print(soup.select_one('path[d]'))['d'])
Try
print(soup.select_one('path[d]'))['d'])
from bs4 import BeautifulSoup

html = """<path fill="none" stroke="#F39C13" stroke-width="3" d="M70,398L80.91495058333334,398L80.91495058333334,
393.12462491393086L139.9525775,393.12462491393086L139.9525775,390.3995549380779L171.26091083333333,
390.3995549380779L171.26091083333333,375.6214167892933L191.91833333333335,375.6214167892933L191.91833333333335,
370.57940817475315L192.15775,370.57940817475315L192.15775,346.8216070234775L192.52608333333333,
346.8216070234775L192.52608333333333,316.5126268923282L193.31799999999998,316.5126268923282L193.31799999999998,
311.17636059522624L195.11049416666665,311.17636059522624L195.11049416666665,294.184572994709L250.7719225,
294.184572994709L250.7719225,289.64175873696803L251.5575775,289.64175873696803L251.5575775,
284.19552891552445L278.176475,284.19552891552445L278.176475,274.12735109627243L317.6176083333333,
274.12735109627243L317.6176083333333,267.6450061351061L361.59108333333336,267.6450061351061L361.59108333333336,
261.7097197920084L376.50305833333334,261.7097197920084L376.50305833333334,257.4876501142978L398.179475,
257.4876501142978L398.179475,253.6807437062263L413.20010833333333,253.6807437062263L413.20010833333333,
244.68390284180637L415.8889416666667,244.68390284180637L415.8889416666667,232.59131014943122L433.19508333333334,
232.59131014943122L433.19508333333334,217.11191560626028L462.73541666666665,217.11191560626028L462.73541666666665,
212.86778950989245L537.1074416666668,212.86778950989245L537.1074416666668,181.49502268135544L572.4932249999999,
181.49502268135544L572.4932249999999,153.38834724724293L579.8101666666666,153.38834724724293L579.8101666666666,
147.33719431459903L585.7403333333334,147.33719431459903L585.7403333333334,132.7568776518106L628.0489416666667,
132.7568776518106L628.0489416666667,127.66153735816481L632.008525,127.66153735816481L632.008525,
120.59249015748499L637.743475,120.59249015748499L637.743475,112.57549162805078L680.1441666666666,
112.57549162805078L680.1441666666666,107.87408149242401L696.3931916666667,107.87408149242401L696.3931916666667,
104.2686095237732L704.7727749999999,104.2686095237732L704.7727749999999,102.36035726070402L733,
102.36035726070402L733,102.36035726070402"></path> """

soup = BeautifulSoup(html, features="lxml")
element = soup.select('path:nth-child(1)')[0]['d']
print(element)