Python BeautifulSoup-在iframe中抓取Web内容

时间:2019-02-04 18:39:45

标签: python web-scraping beautifulsoup

我们有以下URL: https://www.aliexpress.com/store/feedback-score/1665279.html

所需的内容是iframe中的“反馈历史记录”表:

Feedback    1 Month 3 Months    6 Months
Positive (4-5 Stars)    154 562 1,550
Neutral (3 Stars)   8   19  65
Negative (1-2 Stars)    8   20  57
Positive feedback rate  95.1%   96.6%   96.5%

我们如何提取它?

1 个答案:

答案 0 :(得分:2)

您只需要获取src的{​​{1}}属性,然后请求并解析其内容:

iframe

结果:

Feedback        1 Month         3 Months        6 Months
Positive (4-5 Stars)    154     562     1,550
Neutral (3 Stars)       8       19      65
Negative (1-2 Stars)    8       20      57
Positive feedback rate  95.1%   96.6%   96.5%