Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.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
美丽的汤:使用cerain属性提取xml值_Xml_Web Scraping_Beautifulsoup - Fatal编程技术网

美丽的汤:使用cerain属性提取xml值

美丽的汤:使用cerain属性提取xml值,xml,web-scraping,beautifulsoup,Xml,Web Scraping,Beautifulsoup,我用它来刮木板游戏机 这是工作良好,并正在获得信息的网站 我想在输出csv中再提取一个元素。这个: <items> <item> <link type="boardgamepublisher" id="1001" value="(Web published)"/> <link type="boardgamepublisher" id="1341" value="something else"/> </item> &l

我用它来刮木板游戏机

这是工作良好,并正在获得信息的网站

我想在输出csv中再提取一个元素。这个:

<items>
 <item>
   <link type="boardgamepublisher" id="1001" value="(Web published)"/>
   <link type="boardgamepublisher" id="1341" value="something else"/>
 </item>  
</items>

id是随机的,我想要的是类型属性“boardgamepublisher”的链接标记的值,并将它们添加到csv字段中(最好是一个单元格中的所有boardgamepublisher)。有时是一个boardgamepublisher,有时是更多。有很多链接元素,所以我需要按它们过滤

 soup = BeautifulSoup(req.content, 'xml')
    items = soup.find_all('item')
    for item in items:
需要添加此代码才能添加发布服务器

第一行返回带有

   <link type="boardgamepublisher" id="1001" value="(Web published)"/>


发布者[“value”]提取value属性的内容

我仍然在寻找更好的建议,因为我担心这个解决方案会非常缓慢

   <link type="boardgamepublisher" id="1001" value="(Web published)"/>
   <link type="boardgamepublisher" id="1341" value="something else"/>