Open
Conversation
Alperencode
suggested changes
Nov 16, 2021
Alperencode
left a comment
There was a problem hiding this comment.
You should use more specified variable names and definitions to keep your code clean. I just suggested and change them for you.
| 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.
You can use:
print(bs.find_all("div",class_="s-image-square-aspect"))
| 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.
create a variable for div section, then use this on for loop:
div_section = bs.find_all("div",class_="s-image-square-aspect")
| print(bs.title.string) | ||
| print(bs.find_all("div", {"class" : "s-image-square-aspect"})) | ||
|
|
||
| for x in bs.find_all("div", {"class" : "s-image-square-aspect"}): |
There was a problem hiding this comment.
use more specified variable names like:
for div in div_section:
print(div.text)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
web scraping program...