2016-07-19 2 views
0

Google Playストアページからアプリ名とVisit Page Urlをスクラップするためのコードを作成しました。Google Playストアの訪問ページとアプリ名に関する情報を収集する

ASOS - ASOS(ライン1120)

訪問のウェブサイトを取得する - http://www.asos.comゲット - (Q =)(ライン1121のソースコードを)

url = 'https://play.google.com/store/apps/details?id=com.asos.app' 
r = requests.get(url) 

final=[] 
for line in r.iter_lines(): 
    if count == 1120: 
     soup = BeautifulSoup(line) 
     for row in soup.findAll('a'): 
       u=row.find('span') 
       t = u.string 
       print t 
    elif count == 1121: 
     soup = BeautifulSoup(line) 
     for row in soup.findAll('a'): 
       u=row.get('href') 
       print u 
    count = count + 1 

私はここにHTMLを印刷するように見えることはできません。編集内容を開いてください。しかし、ここで私を助けてください!

答えて

1

BeautifulSoupは、利用しなければならない多くの機能を提供します。手始めに

、スクリプトは次のように削減することができます。

import requests 
from bs4 import BeautifulSoup 

url = 'https://play.google.com/store/apps/details?id=com.asos.app' 
r = requests.get(url) 

soup = BeautifulSoup(r.content, "html.parser") 

for a in soup.find_all('a', {'class': 'dev-link'}): 
    print "Found the URL:", a['href'] 

BS4は、生のHTMLコンテンツを解析することができますし、データ型を経由して、それを反復処理することができます。このシナリオでは、クラス名dev-linkの特定のhrefリンクが必要です。

Found the URL: https://www.google.com/url?q=http://www.asos.com&sa=D&usg=AFQjCNGl4lHIgnhUR3y414Q8idAzJvASqw 
Found the URL: mailto:[email protected] 
Found the URL: https://www.google.com/url?q=http://www.asos.com/infopages/pgeprivacy.aspx&sa=D&usg=AFQjCNH-hW1H0fYlsCjp4ERbVh29epqaXA 

私はあなたが望む結果を得るために、もう少しそれを微調整することができると確信していますが詳細については、BS4を参照してください==>https://www.crummy.com/software/BeautifulSoup/bs4/doc/

+0

おかげAを:、あなたの次の出力を取得しそうアドバイスのためのトン! – Blabber

+0

私は喜んで、私が助けることができてうれしい。 – Carlos

+0

は、私が6000-7000のような呼び出しを持っているので、これに代わる手段です。私はここに何か提案に感謝します! – Blabber

関連する問題