@@ -48,10 +48,12 @@ def get(
48
48
49
49
Args:
50
50
url (str): The URL to send the GET request to.
51
- request_timeout (Optional[int]): The request timeout in seconds. Defaults to None (no timeout).
51
+ request_timeout (Optional[int]): The request timeout in seconds.
52
+ Defaults to None (no timeout).
52
53
53
54
Returns:
54
- Optional[requests.Response]: The response object returned by the GET request, or None if an error occurred.
55
+ Optional[requests.Response]: The response object returned by the
56
+ GET request, or None if an error occurred.
55
57
"""
56
58
try :
57
59
config = prepare_config (request_timeout = request_timeout )
@@ -73,22 +75,33 @@ def get(
73
75
def add_user_agent_header (self , user_agent_type : str ) -> None :
74
76
"""
75
77
Adds a user agent header to the session headers.
76
- There is no way to indicate a specific User-Agent, but you can let us know which user-agent type you would like us to use.
78
+ There is no way to indicate a specific User-Agent, but you can let us
79
+ know which user-agent type you would like us to use.
77
80
78
81
Args:
79
- user_agent_type (str): The user agent to add. Must be one of the following:
82
+ user_agent_type (str): The user agent to add. Must be one of the
83
+ following:
80
84
- "desktop" - A User-Agent of a desktop browser.
81
- - "desktop_chrome" - A User-Agent of one of the latest versions of a desktop Chrome browser.
82
- - "desktop_edge" - A User-Agent of one of the latest versions of a desktop Edge browser.
83
- - "desktop_firefox" - A User-Agent of one of the latest versions of a desktop Firefox browser.
84
- - "desktop_opera" - A User-Agent of one of the latest versions of a desktop Opera browser.
85
- - "desktop_safari" - A User-Agent of one of the latest versions of a desktop Safari browser.
85
+ - "desktop_chrome" - A User-Agent of one of the latest versions of
86
+ a desktop Chrome browser.
87
+ - "desktop_edge" - A User-Agent of one of the latest versions of
88
+ a desktop Edge browser.
89
+ - "desktop_firefox" - A User-Agent of one of the latest versions of
90
+ a desktop Firefox browser.
91
+ - "desktop_opera" - A User-Agent of one of the latest versions of
92
+ a desktop Opera browser.
93
+ - "desktop_safari" - A User-Agent of one of the latest versions of
94
+ a desktop Safari browser.
86
95
- "mobile" - A User-Agent of a mobile browser.
87
- - "mobile_android" - A User-Agent of one of the latest versions of an Android mobile browser.
88
- - "mobile_ios" - A User-Agent of one of the latest versions of an iOS mobile browser.
96
+ - "mobile_android" - A User-Agent of one of the latest versions of
97
+ an Android mobile browser.
98
+ - "mobile_ios" - A User-Agent of one of the latest versions of
99
+ an iOS mobile browser.
89
100
- "tablet" - A User-Agent of a tablet browser.
90
- - "tablet_android" - A User-Agent of one of the latest versions of an Android tablet browser.
91
- - "tablet_ios" - A User-Agent of one of the latest versions of an iOS tablet browser.
101
+ - "tablet_android" - A User-Agent of one of the latest versions of
102
+ an Android tablet browser.
103
+ - "tablet_ios" - A User-Agent of one of the latest versions of
104
+ an iOS tablet browser.
92
105
93
106
Returns:
94
107
None
@@ -116,8 +129,10 @@ def add_parse_header(
116
129
Adds a parse header to the session headers.
117
130
118
131
Args:
119
- parse (bool, optional): Whether to enable parsing. Defaults to False.
120
- parsing_instructions (dict, optional): Instructions for parsing. Defaults to None.
132
+ parse (bool, optional): Whether to enable parsing. Defaults to
133
+ False.
134
+ parsing_instructions (dict, optional): Instructions for parsing.
135
+ Defaults to None.
121
136
122
137
Returns:
123
138
None
@@ -139,7 +154,8 @@ def _is_universal_source(self) -> bool:
139
154
Checks if the URL to scrape belongs to a universal source.
140
155
141
156
Returns:
142
- bool: True if the URL belongs to a universal source, False otherwise.
157
+ bool: True if the URL belongs to a universal source, False
158
+ otherwise.
143
159
"""
144
160
parsed_url = urlparse (self ._url_to_scrape )
145
161
if any (
@@ -153,10 +169,12 @@ def _is_universal_source(self) -> bool:
153
169
def add_geo_location_header (self , geo_location : str ) -> None :
154
170
"""
155
171
Adds a geo location header to the session headers.
156
- In some cases, you may need to indicate the geographical location that the result should be adapted for.
172
+ In some cases, you may need to indicate the geographical location that
173
+ the result should be adapted for.
157
174
158
175
Args:
159
- geo_location (str): The geo location to add. Accepted values depend on the URL you would like us to scrape.
176
+ geo_location (str): The geo location to add. Accepted values depend
177
+ on the URL you would like us to scrape.
160
178
161
179
Returns:
162
180
None
0 commit comments