-
Notifications
You must be signed in to change notification settings - Fork 469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Web-scraping #693
base: main
Are you sure you want to change the base?
Web-scraping #693
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from bs4 import BeautifulSoup | ||
import requests | ||
|
||
headers = { | ||
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36' | ||
} | ||
|
||
res = requests.get("https://www.amazon.in/s?bbn=976419031&rh=n%3A976419031%2Cp_89%3Arealme&dc&qid=1624216249&rnid=3837712031&ref=lp_976420031_nr_p_89_3", headers = headers) | ||
bs = BeautifulSoup(res.text, "html.parser") | ||
print(bs.title.string) | ||
print(bs.find_all("div", {"class" : "s-image-square-aspect"})) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. create a variable for div section, then use this on for loop: |
||
for x in bs.find_all("div", {"class" : "s-image-square-aspect"}): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use more specified variable names like: |
||
print(x.text) | ||
# data = x.text | ||
# print(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use:
print(bs.find_all("div",class_="s-image-square-aspect"))