Reputation: 11433
We have this URL: https://www.aliexpress.com/store/feedback-score/1665279.html
And the needed content is the "Feedback History" table, which is inside an 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%
How do we extract it?
Upvotes: 3
Views: 10578
Reputation: 11157
You just need to obtain the src
attribute of the iframe
, and then request and parse its content:
import requests
from bs4 import BeautifulSoup
s = requests.Session()
r = s.get("https://www.aliexpress.com/store/feedback-score/1665279.html")
soup = BeautifulSoup(r.content, "html.parser")
iframe_src = soup.select_one("#detail-displayer").attrs["src"]
r = s.get(f"https:{iframe_src}")
soup = BeautifulSoup(r.content, "html.parser")
for row in soup.select(".history-tb tr"):
print("\t".join([e.text for e in row.select("th, td")]))
Result:
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%
Upvotes: 11