0

我有这个代码:

import urllib
from bs4 import BeautifulSoup
import time

url = "http://www.downloadcrew.com/article/31121-magix_movie_edit_pro_2014_premium"
pageUrl = urllib.urlopen(url)
time.sleep(2)
soup = BeautifulSoup(pageUrl)

for a in  soup.select("div.downloadLink a[href]"):
    print "downloadlink: "+a["href"]

for b in soup.select("h1#articleTitle"):
    print b

for c in soup.select("table.detailsTable"):
    print c

我想要的是应用程序名称、更新日期、开发者和下载链接。当我尝试运行它时,输出将是每个标签内的所有内容。

4

1 回答 1

1

这是得到你想要的代码:

import urllib
from bs4 import BeautifulSoup
import time

url = "http://www.downloadcrew.com/article/31121-magix_movie_edit_pro_2014_premium"
pageUrl = urllib.urlopen(url)
time.sleep(2)
soup = BeautifulSoup(pageUrl)

for a in  soup.select("div.downloadLink a[href]"):
    print "downloadlink: " + "?" + a["href"].split("?")[1].split(",")[0]

for b in soup.select("h1#articleTitle"):
    print b.contents[0].strip()

for c in soup.findAll("th"):
    if c.text == "Date Updated:":
        print c.parent.td.text
    elif c.text == "Developer:":
        print c.parent.td.text

但是您无法使用该 URL 下载文件。您将需要检查 JavaScript 源文件以查看javascript:checkDownload()获取实际文件位置的方法。

于 2013-09-18T08:19:57.180 回答