Regex 使用beautifulsoup从html内容中提取数据-html解析

Regex 使用beautifulsoup从html内容中提取数据-html解析,regex,python-2.7,html-parsing,beautifulsoup,Regex,Python 2.7,Html Parsing,Beautifulsoup,我使用beautifulsoup库编写的脚本内容如下: <meta content="Free" itemprop="price" /> 好的,明白了!只需通过以下方法访问值(对于上述情况): 不需要添加正则表达式。只要通读一下文档就可以了 好的,明白了!只需通过以下方法访问值(对于上述情况): 不需要添加正则表达式。只要通读一下文档就可以了 你为什么要做soup=beautifulsou(“”).join(pageHtml))你为什么要做soup=beautifulsou(“”

我使用beautifulsoup库编写的脚本内容如下:

 <meta content="Free" itemprop="price" />

好的,明白了!只需通过以下方法访问值(对于上述情况):


不需要添加正则表达式。只要通读一下文档就可以了

好的,明白了!只需通过以下方法访问值(对于上述情况):


不需要添加正则表达式。只要通读一下文档就可以了

你为什么要做
soup=beautifulsou(“”).join(pageHtml))
你为什么要做
soup=beautifulsou(“”.join(pageHtml))
 <div class="content" itemprop="datePublished">November 4, 2013</div>
   from BeautifulSoup import BeautifulSoup
   import urllib
   import re

   pageFile = urllib.urlopen("https://play.google.com/store/apps/details?id=com.ea.game.fifa14_na")
   pageHtml = pageFile.read()
   pageFile.close()

   soup = BeautifulSoup("".join(pageHtml))
   item = soup.find("meta", {"itemprop":"price"})

   print item
   items = soup.find("div",{"itemprop":"datePublished"})

   print items
   from BeautifulSoup import BeautifulSoup
   import urllib


   pageFile = urllib.urlopen("https://play.google.com/store/apps/details?id=com.ea.game.fifa14_na")
   pageHtml = pageFile.read()
   pageFile.close()

   soup = BeautifulSoup("".join(pageHtml))
   item = soup.find("meta", {"itemprop":"price"}) # meta content="Free" itemprop="price"
   print item['content']
   items = soup.find("div",{"itemprop":"datePublished"})
   print items.string