Created
January 30, 2014 15:56
-
-
Save cursedcoder/8711732 to your computer and use it in GitHub Desktop.
Memory leak PyQT5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt5.QtCore import QUrl | |
from PyQt5.QtWidgets import QApplication | |
from PyQt5.QtWebKitWidgets import QWebView | |
from PyQt5.QtWebKit import QWebSettings | |
class Crawler(QWebView): | |
def __init__(self): | |
QWebView.__init__(self) | |
self.settings().setMaximumPagesInCache(0) | |
self.settings().setObjectCacheCapacities(0, 0, 0) | |
self.settings().setOfflineStorageDefaultQuota(0) | |
self.settings().setOfflineWebApplicationCacheQuota(0) | |
#self.settings().setAttribute(QWebSettings.AutoLoadImages, False) | |
self.loadFinished.connect(self._result_available) | |
def start(self): | |
self.load(QUrl('http://google.com')) | |
self.load(QUrl('http://facebook.com')) | |
self.load(QUrl('http://youtube.com')) | |
self.load(QUrl('http://yahoo.com')) | |
self.load(QUrl('http://amazon.com')) | |
self.load(QUrl('http://bing.com')) | |
self.load(QUrl('http://ebay.com')) | |
self.load(QUrl('http://wikipedia.org')) | |
self.load(QUrl('http://craigslist.org')) | |
self.load(QUrl('http://linkedin.com')) | |
self.load(QUrl('http://live.com')) | |
self.load(QUrl('http://twitter.com')) | |
self.load(QUrl('http://blogspot.com')) | |
self.load(QUrl('http://aol.com')) | |
self.load(QUrl('http://go.com')) | |
self.load(QUrl('http://pinterest.com')) | |
self.load(QUrl('http://msn.com')) | |
self.load(QUrl('http://tumblr.com')) | |
self.load(QUrl('http://cnn.com')) | |
self.load(QUrl('http://ask.com')) | |
self.load(QUrl('http://huffingtonpost.com')) | |
self.load(QUrl('http://netflix.com')) | |
self.load(QUrl('http://paypal.com')) | |
self.load(QUrl('http://weather.com')) | |
self.load(QUrl('http://conduit.com')) | |
self.load(QUrl('http://espn.go.com')) | |
self.load(QUrl('http://instagram.com')) | |
self.load(QUrl('http://wordpress.com')) | |
self.load(QUrl('http://bankofamerica.com')) | |
self.load(QUrl('http://akamihd.net')) | |
self.load(QUrl('http://imdb.com')) | |
self.load(QUrl('http://chase.com')) | |
self.load(QUrl('http://microsoft.com')) | |
self.load(QUrl('http://about.com')) | |
self.load(QUrl('http://avg.com')) | |
self.load(QUrl('http://pornhub.com')) | |
self.load(QUrl('http://comcast.net')) | |
self.load(QUrl('http://foxnews.com')) | |
self.load(QUrl('http://apple.com')) | |
self.load(QUrl('http://walmart.com')) | |
self.load(QUrl('http://xhamster.com')) | |
self.load(QUrl('http://mywebsearch.com')) | |
self.load(QUrl('http://wellsfargo.com')) | |
self.load(QUrl('http://xvideos.com')) | |
self.load(QUrl('http://yelp.com')) | |
self.load(QUrl('http://imgur.com')) | |
self.load(QUrl('http://nytimes.com')) | |
self.load(QUrl('http://nbcnews.com')) | |
self.load(QUrl('http://cnet.com')) | |
self.load(QUrl('http://reddit.com')) | |
self.load(QUrl('http://adobe.com')) | |
self.load(QUrl('http://ehow.com')) | |
self.load(QUrl('http://pandora.com')) | |
self.load(QUrl('http://pch.com')) | |
self.load(QUrl('http://hulu.com')) | |
self.load(QUrl('http://zedo.com')) | |
self.load(QUrl('http://etsy.com')) | |
self.load(QUrl('http://flickr.com')) | |
self.load(QUrl('http://outbrain.com')) | |
self.load(QUrl('http://optmd.com')) | |
self.load(QUrl('http://indeed.com')) | |
self.load(QUrl('http://livejasmin.com')) | |
self.load(QUrl('http://zillow.com')) | |
self.load(QUrl('http://target.com')) | |
self.load(QUrl('http://xnxx.com')) | |
self.load(QUrl('http://homedepot.com')) | |
self.load(QUrl('http://redtube.com')) | |
self.load(QUrl('http://answers.com')) | |
self.load(QUrl('http://thepiratebay.sx')) | |
self.load(QUrl('http://att.com')) | |
self.load(QUrl('http://shopathome.com')) | |
self.load(QUrl('http://wikia.com')) | |
self.load(QUrl('http://dailymail.co.uk')) | |
self.load(QUrl('http://usps.com')) | |
self.load(QUrl('http://babylon.com')) | |
self.load(QUrl('http://ups.com')) | |
self.load(QUrl('http://bestbuy.com')) | |
self.load(QUrl('http://youporn.com')) | |
self.load(QUrl('http://reference.com')) | |
self.load(QUrl('http://godaddy.com')) | |
self.load(QUrl('http://groupon.com')) | |
self.load(QUrl('http://deviantart.com')) | |
self.load(QUrl('http://usatoday.com')) | |
self.load(QUrl('http://pof.com')) | |
self.load(QUrl('http://capitalone.com')) | |
self.load(QUrl('http://bbc.co.uk')) | |
self.load(QUrl('http://washingtonpost.com')) | |
self.load(QUrl('http://match.com')) | |
self.load(QUrl('http://drudgereport.com')) | |
self.load(QUrl('http://mlb.com')) | |
self.load(QUrl('http://tripadvisor.com')) | |
self.load(QUrl('http://pogo.com')) | |
self.load(QUrl('http://verizonwireless.com')) | |
self.load(QUrl('http://blogger.com')) | |
self.load(QUrl('http://buzzfeed.com')) | |
self.load(QUrl('http://doublepimp.com')) | |
self.load(QUrl('http://inksr.com')) | |
self.load(QUrl('http://delta-search.com')) | |
self.load(QUrl('http://fedex.com')) | |
self.load(QUrl('http://inksdata.com')) | |
self.load(QUrl('http://oyodomo.com')) | |
self.load(QUrl('http://aweber.com')) | |
self.load(QUrl('http://abcnews.go.com')) | |
self.load(QUrl('http://vimeo.com')) | |
self.load(QUrl('http://hootsuite.com')) | |
self.load(QUrl('http://bleacherreport.com')) | |
self.load(QUrl('http://lowes.com')) | |
self.load(QUrl('http://yellowpages.com')) | |
self.load(QUrl('http://americanexpress.com')) | |
self.load(QUrl('http://tube8.com')) | |
self.load(QUrl('http://yieldmanager.com')) | |
self.load(QUrl('http://salesforce.com"')) | |
def _result_available(self, ok): | |
print('got it!') | |
self.settings().clearMemoryCaches() # it doesn't help | |
self.settings().clearIconDatabase() | |
self.start() # next try | |
if __name__ == '__main__': | |
app = QApplication([]) | |
crawler = Crawler() | |
crawler.start() | |
app.exec_() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment