MCPcopy
hub / github.com/SpiderClub/haipproxy / proxy_check

Method proxy_check

crawler/spiders/base.py:147–161  ·  view source on GitHub ↗

check whether the proxy ip and port are valid :param ip: proxy ip value :param port: proxy port value :return: True or False

(self, ip, port)

Source from the content-addressed store, hash-verified

145 return protocols
146
147 def proxy_check(self, ip, port):
148 """
149 check whether the proxy ip and port are valid
150 :param ip: proxy ip value
151 :param port: proxy port value
152 :return: True or False
153 """
154 try:
155 ipaddress.ip_address(ip)
156 p = int(port)
157 if p > 65535 or p <= 0:
158 return False
159 except ValueError:
160 return False
161 return True
162
163 def construct_proxy_url(self, scheme, ip, port):
164 """construct proxy urls so spiders can directly use them"""

Callers 3

parse_commonMethod · 0.95
parse_jsonMethod · 0.95
parse_raw_textMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected