
Handy C to teach you to use C to put a "vest" on the browser
The old iron engaged in web page collection must have encountered the IP blocked embarrassing, this time you need to give the browser to wear a "cloak". Today we will chatter how to use CefSharp this magic tool, in C to the browser to hang a proxy IP. do not panic, the operation is simpler than cooking noodles!
Don't be lazy with the prep.
First, I'll straighten out the three-piece suit:
1. Visual Studio (2017+ version is solid)
2. NuGet package manager to install CefSharp.WinForms (version 87+ recommended)
3. reliable proxy IP resources - such as ipipgo family dynamic residential IP
Focused Reminder:Don't use free agents! Nine out of ten free proxies are pitted, and the remaining one is being pitted. I used a free proxy in a previous test, and 8 out of 10 times it wouldn't load the captcha, and it was only after I switched to ipipgo's dynamic residential IP that it went smoothly.
Five Steps to Agent Configuration
Follow the code example below to operate, the eye will hand:
// Initialize the configuration object
var settings = new CefSettings();
// The key code is here! Replace it with your proxy information
settings.CefCommandLineArgs.Add("--proxy-server", "http://username:password@ipipgo-proxy.com:8080");
// Start the browser
Cef.Initialize(settings); var browser = new ChromiumWebWorks.com; // Start the browser.
var browser = new ChromiumWebBrowser("https://whatismyipaddress.com");
Note that username and password should be replaced with the authentication information provided by ipipgo, and there are ready-made code snippets in their API documentation that can be copied directly for homework.
Dynamic IP switching black technology
When you need to rotate IPs, don't be a fool and restart your browser, try this tawdry maneuver:
// Get new IP (using ipipgo's API as an example)
var newProxy = GetNewProxyFromIpipgo();
// Modify the runtime proxy
browser.GetBrowser().GetHost().RequestContext.SetPreference("proxy", new Dictionary)
{
{"mode", "fixed_servers"}, {"server", newProxy", newProxy.SetPreference()
{"server", newProxy.Address}
}, out _);
ipipgo's API response speed is measured at about 200ms, and you basically can't feel the lag when switching. Their TK line is particularly suitable for the need to frequently change IP scenarios, who uses who knows.
Common Rollover Scene First Aid Kit
Q: The code runs but the IP doesn't change?
A: First check three things: ① proxy address format is not correct ② account password expired ③ firewall whether the request is blocked. Recommended to use ipipgo client to test the proxy availability first!
Q: HTTPS website failed to load?
A: 80% is a certificate problem, add it in the initialization settings:
settings.CefCommandLineArgs.Add("--ignore-certificate-errors", "1");
Q: How can I tell if the proxy is really in effect?
A: Visit the IP detection page on the ipipgo website, and you can see that the IP becomes a proxy address and it is stable.
How to choose a proxy service provider?
Straight to the dry comparison table:
| functionality | ipipgo dynamic homes | Other Regular Agents |
|---|---|---|
| IP purity | carrier-grade | Mixed use of public pools |
| Concurrency support | 500+ threads | 50 threads and it's gone. |
| price threshold | From $7.67/GB | Lots of hidden costs |
Frankly speaking, with CefSharp to engage in the development of the most afraid of proxy instability. Before taking over an e-commerce project, with the ordinary proxy to restart the program more than a dozen times a day, replaced with ipipgo static residential IP, running for a week without dropping the line.
The correct posture of woolgathering
Although ipipgo pricing is already very real, but here to teach you a money-saving trick: do data collection when the dynamic residential and static residential IP mixed use. The session that needs to be logged in uses a static IP to keep the session going, and dynamic IPs are used for ordinary requests, so that the cost can save 30% or so.
Lastly, I would like to say one last thing: the proxy setting is not a one-time thing, remember to update the SDK version regularly. Last month, a brother was using a three-year-old CefSharp 51 version, how could not match the proxy, upgrade to the latest version immediately see the effect. If you have any problems, ipipgo's technical support responds quickly, basically within half an hour on weekdays.

