网站抓取格式不正确的网站

时间:2020-03-17 05:51:01

标签: python html web-scraping beautifulsoup format

我正在抓取一个网站链接为“ https://homeshopping.pk/search.php?q=samsung%20phones”。 Iam在访问div类之一时发现困难。我认为它的格式不正确。提出此问题的原因是为了确认格式是否正确或我做错了什么。

屏幕截图是: This is the website I want to scrape data from.

extension UIApplication {

    var statusBarView: UIView? {
        return value(forKey: "statusBar") as? UIView
    }
}

1 个答案:

答案 0 :(得分:1)

这是东西从-https://api-v3.findify.io/v3/search?user[uid]=TW1bcavcZKWeb32z&user[sid]=6kn0FcKb4QjgMz60&user&t_client=1584424566753&key=cae15cfe-508b-41d1-a019-161c02ffd97c&q=samsung%20phones

加载产品的地方

现在,这些参数固定了吗?我一点都不知道。你能解析一下吗?绝对,用json.loads解析,而不是bs

import requests, json

source = requests.get('https://api-v3.findify.io/v3/search?user[uid]=TW1bcavcZKWeb32z&user[sid]=6kn0FcKb4QjgMz60&user&t_client=1584424566753&key=cae15cfe-508b-41d1-a019-161c02ffd97c&q=samsung%20phones')
j = json.loads(source.content.decode())

for item in j["items"]:
    print(item["title"])