proxy服務(wù)器 香港(Proxy服務(wù)器)
There are many proxy servers in Hong Kong. Some of the most popular include Hide My Ass, TigerVPN, TorGuard, ExpressVPN and VyprVPN. Each of these services offer different features to meet your needs such as dedicated IP addresses for anonymity, data encryption for security and fast speeds for improved streaming performance.
Proxy服務(wù)器# 轉(zhuǎn)發(fā)客戶端的請(qǐng)求到代理服務(wù)器
def connect_proxy(self, host, port=80):
self.client.sendall("CONNECT {0}:{1} HTTP/1.1\r\n\r\n".format(host, port))
response = b''
while True:
data = self.client.recv(1024)
if not data: break
response += data
# 如果HTTP頭部結(jié)束,則退出循環(huán),不在接收數(shù)據(jù)了。這里主要是弄明白HTTP響應(yīng)長(zhǎng)什么樣子的~ 你可以自己用telnet來驗(yàn)證一下~
index = response.find('\r\n\r\n') + 4 # 找到頭部數(shù)據(jù)尾部的位置+4即為body內(nèi)容開始的位置 (\.runoob\.com/http/)
if index > 3: break # 如果找到header尾部(正常情況應(yīng)該大于3) 則表明頭信元讀取完成 通常會(huì)出現(xiàn)index=3 的情況 是因?yàn)?\r \n \r \n 有時(shí)會(huì)都一起存在 因而使headersize-3=0 此時(shí)應(yīng)當(dāng)將while循環(huán)break
status_code = int(response[9:12]) # 解包含義參考 https://zh\.wikipedia\.org\/wiki
proxy代理服務(wù)器地址public static void getIpAddr(String ipUrl){
try {
URL url = new URL(ipUrl);// 創(chuàng)建URL
HttpURLConnection conn = (HttpURLConnection)url.openConnection();// 打開連接
conn.setConnectTimeout(3 * 1000); // 設(shè)置超時(shí)時(shí)間 3s內(nèi)未請(qǐng)求到數(shù)據(jù) 就斷開連接
if (conn.getResponseCode() == 200) { // 判斷是否正常響應(yīng)數(shù)據(jù) http請(qǐng)求成功為200
InputStream inStream = conn.getInputStream(); // 獲取輸入流
BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, "utf-8"));// 讀取器,將字符流解釋成字符串
String strRead ;
while ((strRead = reader.readLine()) != null){
System.out.println("IP:"+strRead);
proxy=strRead; //得到IP地址 break; } } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e .printStackTrace(); }}