File tree 1 file changed +7
-5
lines changed
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -19,11 +19,13 @@ def get_amazon_product_data(product: str = "laptop") -> DataFrame:
19
19
"""
20
20
url = f"https://www.amazon.in/laptop/s?k={ product } "
21
21
header = {
22
- "User-Agent" : """Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36
23
- (KHTML, like Gecko)Chrome/44.0.2403.157 Safari/537.36""" ,
22
+ "User-Agent" : (
23
+ "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36"
24
+ "(KHTML, like Gecko)Chrome/44.0.2403.157 Safari/537.36"
25
+ ),
24
26
"Accept-Language" : "en-US, en;q=0.5" ,
25
27
}
26
- soup = BeautifulSoup (requests .get (url , headers = header ).text )
28
+ soup = BeautifulSoup (requests .get (url , headers = header ).text , features = "lxml" )
27
29
# Initialize a Pandas dataframe with the column titles
28
30
data_frame = DataFrame (
29
31
columns = [
@@ -74,8 +76,8 @@ def get_amazon_product_data(product: str = "laptop") -> DataFrame:
74
76
except ValueError :
75
77
discount = float ("nan" )
76
78
except AttributeError :
77
- pass
78
- data_frame .loc [len (data_frame .index )] = [
79
+ continue
80
+ data_frame .loc [str ( len (data_frame .index ) )] = [
79
81
product_title ,
80
82
product_link ,
81
83
product_price ,
You can’t perform that action at this time.
0 commit comments