web2+wed3=web5? 爬虫代理能这么干吗?

探讨Web3与早期http爬虫代理的相似之处,包括直连代理和隧道代理的演变,以及如何根据业务需求选择合适的代理IP。




如果说web2是一把锁住大门的锁,那么web3就是把每个人的锁串联在一起?
去中心化的利用模式终究争议很大,我们今天来聊聊爬虫代理与web2,web3的相似之处。

其实两者的行业发展反而属于倒过来的,早期的http代理,爬虫代理更像是web3的行为,通过网络的透明代理连接到http代理的需求端,这种技术叫作直连代理,一点云里速度最快的代理。

后期由于技术的成熟和代理ip行业的正规化,http代理会通过自家的服务器进行+端口进行转发,俗称隧道代理,隧道在这里也就是服务器的意思。

在我们日常选购http,爬虫代理的时候,需要注意哪些呢?

一、了解业务对代理IP的需求

自己的业务,自己明白有什么要求。一天大概有多少个请求,一天大概需要多少个代理IP,同时需要多少个代理IP发送请求,每个代理IP需要使用多长时间等。了解这些业务需求,再针对性的选择代理IP套餐,将会更加简单,更加准确。

二、了解代理IP套餐各项参数

不同的代理IP套餐,不仅仅是价格不同,还有各种不同的参数属性。例如代理IP池里每天的不重复IP总量,代理IP的有效期,最小提取间隔,单次提取IP数量,IP白名单数量,代理IP支持的协议等等。将代理IP套餐的这些参数属性和自己的业务需求一一对比,看看是否满足需求。

#include <REG51.H> #include <INTRINS.H> #include <STRING.H> #include <stdio.h> // ==================== ???? ==================== // // LCD1602?? sbit LCD_RS = P2^0; sbit LCD_RW = P2^1; sbit LCD_EN = P2^2; #define LCD_DATA_PORT P0 // DS1302?? sbit DS1302_SCLK = P3^6; sbit DS1302_IO = P3^4; sbit DS1302_RST = P3^5; // DS18B20?? sbit DS18B20_DQ = P1^0; // ???? sbit KEY_SET_TIME = P1^1; sbit KEY_SET_ALARM = P1^2; sbit KEY_SUB = P1^3; sbit KEY_ADD = P1^4; // ????? sbit BUZZER = P3^7; // ==================== ???? ==================== // typedef unsigned char uint8; typedef unsigned int uint16; // ==================== ???? ==================== // uint8 g_setMode = 0; // 0:????, 1:????, 2:????, 3:???? uint8 g_hourSet = 0, g_minSet = 0, g_secSet = 0; uint8 g_yearSet = 0, g_monSet = 0, g_daySet = 0; uint8 g_hourAlarm = 0, g_minAlarm = 0; uint8 g_hour = 0, g_min = 0, g_sec = 0; uint8 g_year = 0, g_mon = 0, g_day = 0; int g_temp = 0; char *weekDays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; // ==================== ????(??11.0592MHz) ==================== // void DelayMs(uint16 ms) { uint16 i, j; for (i = 0; i < ms; i++) { for (j = 0; j < 113; j++); // 11.0592MHz??1ms } } void DelayUs(uint8 us) { while (us--) { _nop_(); _nop_(); _nop_(); // 3?????3.25µs(???) } } // ==================== LCD1602???? ==================== // void LCD_WriteCmd(uint8 cmd) { LCD_RS = 0; LCD_RW = 0; LCD_DATA_PORT = cmd; DelayMs(1); LCD_EN = 1; DelayMs(1); LCD_EN = 0; } void LCD_WriteData(uint8 dat) { LCD_RS = 1; LCD_RW = 0; LCD_DATA_PORT = dat; DelayMs(1); LCD_EN = 1; DelayMs(1); LCD_EN = 0; } void LCD_Init(void) { LCD_WriteCmd(0x38); LCD_WriteCmd(0x0C); LCD_WriteCmd(0x06); LCD_WriteCmd(0x01); DelayMs(2); } void LCD_ShowString(uint8 row, uint8 col, char *str) { uint8 addr = (row == 0 ? 0x80 : 0xC0) + col; LCD_WriteCmd(addr); while (*str != &#39;\0&#39;) { LCD_WriteData(*str); str++; DelayMs(1); } } // ==================== DS1302???? ==================== // void DS1302_WriteByte(uint8 addr, uint8 dat) { uint8 i; DS1302_RST = 1; for (i = 0; i < 8; i++) { DS1302_SCLK = 0; DS1302_IO = addr & 0x01; addr >>= 1; DS1302_SCLK = 1; DelayUs(2); } for (i = 0; i < 8; i++) { DS1302_SCLK = 0; DS1302_IO = dat & 0x01; dat >>= 1; DS1302_SCLK = 1; DelayUs(2); } DS1302_RST = 0; } uint8 DS1302_ReadByte(uint8 addr) { uint8 i, dat = 0; DS1302_RST = 1; addr |= 0x01; for (i = 0; i < 8; i++) { DS1302_SCLK = 0; DS1302_IO = addr & 0x01; addr >>= 1; DS1302_SCLK = 1; DelayUs(2); } for (i = 0; i < 8; i++) { DS1302_SCLK = 0; DS1302_SCLK = 1; dat >>= 1; if (DS1302_IO) { dat |= 0x80; } DelayUs(2); } DS1302_RST = 0; return dat; } void DS1302_GetTime(uint8 *hour, uint8 *min, uint8 *sec, uint8 *year, uint8 *mon, uint8 *day) { uint8 temp; temp = DS1302_ReadByte(0x00); *sec = ((temp & 0x70) >> 4) * 10 + (temp & 0x0F); temp = DS1302_ReadByte(0x02); *min = ((temp & 0x70) >> 4) * 10 + (temp & 0x0F); temp = DS1302_ReadByte(0x04); *hour = ((temp & 0x30) >> 4) * 10 + (temp & 0x0F); temp = DS1302_ReadByte(0x07); *day = ((temp & 0x30) >> 4) * 10 + (temp & 0x0F); temp = DS1302_ReadByte(0x08); *mon = ((temp & 0x10) >> 4) * 10 + (temp & 0x0F); temp = DS1302_ReadByte(0x0A); *year = ((temp & 0xF0) >> 4) * 10 + (temp & 0x0F); } void DS1302_SetTime(uint8 hour, uint8 min, uint8 sec, uint8 year, uint8 mon, uint8 day) { DS1302_WriteByte(0x80, ((sec / 10) << 4) | (sec % 10)); DS1302_WriteByte(0x82, ((min / 10) << 4) | (min % 10)); DS1302_WriteByte(0x84, ((hour / 10) << 4) | (hour % 10)); DS1302_WriteByte(0x86, ((day / 10) << 4) | (day % 10)); DS1302_WriteByte(0x88, ((mon / 10) << 4) | (mon % 10)); DS1302_WriteByte(0x8A, ((year / 10) << 4) | (year % 10)); } // ==================== DS18B20???? ==================== // uint8 DS18B20_Init(void) { uint8 res = 1; DS18B20_DQ = 0; DelayUs(750); DS18B20_DQ = 1; DelayUs(100); res = DS18B20_DQ; DelayMs(5); return res; } uint8 DS18B20_ReadByte(void) { uint8 i, dat = 0; for (i = 0; i < 8; i++) { DS18B20_DQ = 0; _nop_(); DS18B20_DQ = 1; dat >>= 1; if (DS18B20_DQ) { dat |= 0x80; } DelayUs(60); } return dat; } void DS18B20_WriteByte(uint8 dat) { uint8 i; for (i = 0; i < 8; i++) { DS18B20_DQ = 0; _nop_(); DS18B20_DQ = dat & 0x01; dat >>= 1; DelayUs(60); DS18B20_DQ = 1; } } int DS18B20_GetTemperature(void) { uint8 temp_l, temp_h; int temp = 0; if (DS18B20_Init() == 0) { DS18B20_WriteByte(0xCC); DS18B20_WriteByte(0x44); DelayMs(750); DS18B20_Init(); DS18B20_WriteByte(0xCC); DS18B20_WriteByte(0xBE); temp_l = DS18B20_ReadByte(); temp_h = DS18B20_ReadByte(); temp = (temp_h << 8) | temp_l; if (temp < 0) { temp = ~temp + 1; temp = -temp; } temp = (temp * 0.0625) * 10; } return temp; } // ==================== ?????? ==================== // bit IsLeapYear(uint8 year) { // 2000-2099??????? year += 2000; if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) { return 1; } return 0; } // ==================== ?????? ==================== // uint8 GetMonthDays(uint8 year, uint8 month) { uint8 days; if (month == 2) { days = IsLeapYear(year) ? 29 : 28; } else if (month == 4 || month == 6 || month == 9 || month == 11) { days = 30; } else { days = 31; } return days; } // ==================== ???? ==================== // uint8 CalculateWeekDay(uint8 year, uint8 month, uint8 day) { // 2000-2099???Zeller????? uint8 c, y, m, d, w; year += 2000; if (month < 3) { month += 12; year--; } c = year / 100; y = year % 100; m = month; d = day; w = y + (y / 4) + (c / 4) - 2 * c + (26 * (m + 1) / 10) + d - 1; w %= 7; return w; } // ==================== ?????? ==================== // void KeyScan(void) { static uint8 keyState = 0; if (KEY_SET_TIME == 0 || KEY_SET_ALARM == 0 || KEY_SUB == 0 || KEY_ADD == 0) { DelayMs(10); if (keyState == 0) { if (KEY_SET_TIME == 0) { g_setMode = (g_setMode + 1) % 4; // ??????:0->1->2->3->0 if (g_setMode == 1) { // ?????? DS1302_GetTime(&g_hourSet, &g_minSet, &g_secSet, &g_year, &g_mon, &g_day); } else if (g_setMode == 2) { // ?????? DS1302_GetTime(&g_hour, &g_min, &g_sec, &g_yearSet, &g_monSet, &g_daySet); } else if (g_setMode == 3) { // ?????? g_hourAlarm = g_hour; g_minAlarm = g_min; } } else if (KEY_SUB == 0) { if (g_setMode == 1) { // ?????? if (g_secSet > 0) { g_secSet--; } else { g_secSet = 59; if (g_minSet > 0) { g_minSet--; } else { g_minSet = 59; g_hourSet = (g_hourSet > 0) ? g_hourSet - 1 : 23; } } } else if (g_setMode == 2) { // ?????? if (g_daySet > 1) { g_daySet--; } else { if (g_monSet > 1) { g_monSet--; } else { g_monSet = 12; if (g_yearSet > 0) { g_yearSet--; } else { g_yearSet = 99; } } g_daySet = GetMonthDays(g_yearSet, g_monSet); } } else if (g_setMode == 3) { // ?????? if (g_minAlarm > 0) { g_minAlarm--; } else { g_minAlarm = 59; g_hourAlarm = (g_hourAlarm > 0) ? g_hourAlarm - 1 : 23; } } } else if (KEY_ADD == 0) { if (g_setMode == 1) { // ?????? g_secSet++; if (g_secSet >= 60) { g_secSet = 0; g_minSet++; if (g_minSet >= 60) { g_minSet = 0; g_hourSet = (g_hourSet + 1) % 24; } } } else if (g_setMode == 2) { // ?????? uint8 maxDays = GetMonthDays(g_yearSet, g_monSet); // ??maxDays?? g_daySet++; if (g_daySet > maxDays) { g_daySet = 1; g_monSet++; if (g_monSet > 12) { g_monSet = 1; g_yearSet = (g_yearSet + 1) % 100; } } } else if (g_setMode == 3) { // ?????? g_minAlarm++; if (g_minAlarm >= 60) { g_minAlarm = 0; g_hourAlarm = (g_hourAlarm + 1) % 24; } } } keyState = 1; } } else { keyState = 0; if (g_setMode == 1) { // ????????????? DS1302_SetTime(g_hourSet, g_minSet, g_secSet, g_year, g_mon, g_day); } else if (g_setMode == 2) { // ????????????? DS1302_SetTime(g_hour, g_min, g_sec, g_yearSet, g_monSet, g_daySet); } } } // ==================== ?????? ==================== // void UpdateDisplay(void) { char dispBuf[20] = {0}; uint8 weekDay; // ????????? DS1302_GetTime(&g_hour, &g_min, &g_sec, &g_year, &g_mon, &g_day); g_temp = DS18B20_GetTemperature(); weekDay = CalculateWeekDay(g_year, g_mon, g_day); // ?????????? if (g_setMode == 2) { // ?????? sprintf(dispBuf, "SET:20%02d-%02d-%02d", g_yearSet, g_monSet, g_daySet); } else { // ????????? sprintf(dispBuf, "20%02d-%02d-%02d %3s", g_year, g_mon, g_day, weekDays[weekDay]); } LCD_ShowString(0, 0, dispBuf); // ??????????????? if (g_setMode == 1) { // ?????? sprintf(dispBuf, "SET:%02d:%02d:%02d %2d.%dC", g_hourSet, g_minSet, g_secSet, g_temp / 10, g_temp % 10); } else if (g_setMode == 3) { // ?????? sprintf(dispBuf, "ALM:%02d:%02d %2d.%dC", g_hourAlarm, g_minAlarm, g_temp / 10, g_temp % 10); } else { // ???? sprintf(dispBuf, "%02d:%02d:%02d %2d.%dC", g_hour, g_min, g_sec, g_temp / 10, g_temp % 10); } LCD_ShowString(1, 0, dispBuf); } // ==================== ?????? ==================== // void CheckAlarm(void) { static bit alarmOn = 0; static uint16 alarmTimer = 0; if (g_setMode != 3 && g_hour == g_hourAlarm && g_min == g_minAlarm && g_sec == 0) { alarmOn = 1; alarmTimer = 0; } if (alarmOn) { BUZZER = ~BUZZER; // ????? DelayMs(100); alarmTimer++; // ????10?????? if (alarmTimer >= 100) { alarmOn = 0; BUZZER = 0; } } } // ==================== ?????? ==================== // void CheckHourMusic(void) { if (g_min == 0 && g_sec == 0 && g_setMode == 0) { BUZZER = 1; DelayMs(500); BUZZER = 0; } } // ==================== ??? ==================== // void main() { LCD_Init(); DS1302_SetTime(12, 0, 0, 24, 8, 1); // ????:2024?8?1?12:00:00 while (1) { KeyScan(); UpdateDisplay(); CheckAlarm(); CheckHourMusic(); DelayMs(100); } }修改这个代码,使这个代码可以正常运行0错误
06-18
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值