2016-09-13 5 views
-3

私はPython(そしてSQL、SAS、そして少しのRの外で多くのコーディングがあります)が新しく、これを使ってさまざまな数のデータからデータセットを構築しようとしていますウェブページ。あなたの助けを前にありがとう。Python Site Scrape Help Needed

私はPython 3.4.4を使用しており、サイトのコードを正常に取得しましたが、必要な特定のデータ要素/メトリックを分離する正規表現コードの作成に問題があります。以下はウェブページのコードのサンプルであり、tdclassステートメント間で整数だけを分離したいと考えています。

<tr class="Company"><td class="Company"> <ahref="http://www.theacsi.org/index.php?option=com_content&view=article&id=149&catid=&Itemid=214&amp;c=Liz+Claiborne&amp;i=Apparel" id="L">Liz Claiborne</a> </td><td class="Baseline"> 84 </td><td class="Y1995"> 81 </td><td class="Y1996"> 81 </td><td class="Y1997"> 77 </td><td class="Y1998"> 78 </td><td class="Y1999"> 76 </td><td class="Y2000"> 79 </td><td class="Y2001"> 79 </td><td class="Y2002"> 80 </td><td class="Y2003"> 78 </td><td class="Y2004"> 79 </td><td class="Y2005"> 78 </td><td class="Y2006"> 81 </td><td class="Y2007"> 79 </td><td class="Y2008"> 79 </td><td class="Y2009"> 82 </td><td class="Y2010"> 79 </td><td class="Y2011"> 79 </td><td clas 
+0

私はこのページを見て、regexを作るために華麗です:https://txt2re.com/ –

答えて

0

他の擦っているソフトはもちろんのこと、lxmlとxpathを見たいと思うかもしれません。 Aeraのポストの数千。あなたが他のモジュールを使用して、文字列から特定のテキストを抽出する方法についての情報を便利提供RE(正規表現)モジュールを構築使用使用したいといけない場合

http://docs.python-guide.org/en/latest/scenarios/scrape/

:下のリンクをチェックしてください。