2017-02-06 23 views
2

悪夢を抱いているので、美しいスープを使ったデスクトップスクレーパーを作っていますが、今はそれをしようとしていますが、それでコーディーにベースコードを追加するのは正しい悪夢です。 。構文エラー、と率直に言って、私はちょうどそれを試してみて、インポートする方法に開始するために理解していないBeautiful Soup Kodiスクレーパー

ここでは私のデスクトップのコードです:

あなたが持っているでしょう

url = input("Enter the direct url for the Tv Show you wish to pull: ") 
 
tvname = input("Enter the name of the TV Show: ") 
 
ui = tvname + '.xml' 
 
response = opener.open(url) 
 
page = response.read() 
 
soup = BeautifulSoup(page, "html.parser") 
 
tv_urls = [] 
 
newfile = open(ui, "w") 
 

 
def get_soup(url): 
 
\t response = opener.open(url) 
 
\t page = response.read() 
 
\t soup = BeautifulSoup(page, "html.parser") 
 
\t return soup 
 

 
soup = get_soup(url) 
 
seasonepisode =(soup.find_all('td', {'width' : '100%'})[-2].string) 
 
cols=soup.find_all('td', { 'width' : '100%', 'class' : 'entry'}) 
 
all_links = [col.find('a').get('href') for col in cols] 
 
tv_urls.extend(all_links) 
 

 
for url in tv_urls: 
 
\t soup = get_soup(url) 
 
\t title = soup.title.string 
 
\t thumbnail=soup.select_one('td.summary img[src]')['src'] 
 
\t cols=soup.find_all('td', { 'width' : '100%', 'class' : 'entry'}) 
 
\t all_links = [col.find('a').get('href') for col in cols][1:] 
 
\t string='<item>\n<title>[COLOR lime]' + title + '[/COLOR]</title>\n' 
 
\t for link in all_links: 
 
\t \t string = string + '<link>' + link + '</link>\n' 
 
\t string=string+'<thumbnail>' + thumbnail + '</thumbnail>\n<fanart> </fanart>\n</item>\n\n' 
 
\t newfile.write(string) 
 
\t print((title + ' Tv links scraped')) 
 

 
print('Done Master Nemzzy') 
 
newfile.close()

+0

ここに私のデスクトップのコードは次のとおりです。 –

+0

私は理解していない申し訳ありませんがthequestionwasが人々を狙って、上記KODIはコディでは動作しませんなぜ、上記のコードがうまくいかないのか知っているので、kodiを知っている人は、何が変わる必要があるのか​​、何が必要なのかを知っているでしょう。 –

答えて

1

Python 2を使用してアドオンを使用する.xmlを使用して依存関係をインポートします。

+0

私はkodi 2.7のために移植しています。私はre.compile –

+0

を使ってスクレーパーを作り直さなければならないかもしれません。あなたはkodiのログファイルを持っていますか? – Razze

0

アドオンxmlでbs4モジュールをインポートしましたか?ない場合は、以下のように、あなたはaddon.xmlにインポートscript.module.bs4を持っている:

<requires> 
    <import addon="script.module.beautifulSoup4" version="3.3.0"/> 
</requires> 
関連する問題