views:

267

answers:

3

I'm slowly building a web browser in PyQt4 and like the speed i'm getting out of it. However, I want to combine easylist.txt with it. I believe adblock uses this to block http requests by the browser.

How would you go about it using python/PyQt4?

[edit1] Ok. I think i've setup Privoxy. I haven't setup any additional filters and it seems to work. The PyQt4 i've tried to use looks like this

self.proxyIP = "127.0.0.1"
self.proxyPORT= 8118
proxy = QNetworkProxy()
proxy.setType(QNetworkProxy.HttpProxy)
proxy.setHostName(self.proxyIP)
proxy.setPort(self.proxyPORT)
QNetworkProxy.setApplicationProxy(proxy)

However, this does absolutely nothing and I cannot make sense of the docs and can not find any examples.

[edit2] I've just noticed that i'f I change self.proxyIP to my actual local IP rather than 127.0.0.1 the page doesn't load. So something is happening.

A: 

Is this question about web filtering?

Then try use some of external web-proxy, for sample Privoxy (http://en.wikipedia.org/wiki/Privoxy).

Denis Barmenkov
Yeah, web filtering. If privoxy does what I need that would save effort. Would it be more efficient to prevent requests rather than block them?
regomodo
Yes, definitely. If you block it, you still load the resource (image, script, whatever); the request is still made. If you prevent the request, no loading happens.
musicfreak
Prevent... block..What the difference here? It may be difficult to rewrite HTML code for blocking G00gle Ads (for sample) but easy to catch and block requests by URL.
Denis Barmenkov
A: 

The easylist.txt file is simply plain text, as demonstrated here: http://adblockplus.mozdev.org/easylist/easylist.txt

lines beginning with [ and also ! appear to be comments, so it is simply a case of sorting through the file, and searching for the correct things in the url/request depending upon the starting character of the line in the easylist.txt file.

Marineio
I already knew what was in the list. I'm just trying to see if it's possible to block requests or prevent them from happening.
regomodo
A: 

Privoxy is solid. If you want it to be completely API based though, check out the BrightCloud web filtering API as well.

Chris Harris