I wrote a code snippet to clear the web, which actually works with it with a single URL, but as soon as I put more than 2 ursl in .txt, it tells me "Segmentation Error". I do not know where the problem is. Any help would be appreciated.
import sys import time import gc from bs4 import BeautifulSoup from PyQt4.QtGui import * from PyQt4.QtCore import * from PyQt4.QtWebKit import * class Render(QWebPage): def __init__(self, url): self.app = QApplication(sys.argv) QWebPage.__init__(self) self.loadFinished.connect(self._loadFinished) self.mainFrame().load(QUrl(url)) self.app.exec_() def _loadFinished(self, result): self.frame = self.mainFrame() #self.deleteLater() self.app.quit() with open('/blah/blah/blah/blah/blah.txt') as f: urls = f.read().splitlines() for i in urls: r = Render(i) soup = BeautifulSoup(unicode(r.frame.toHtml())) summary = soup.find('div',{'style' : 'padding-top:10px;'}) tables = summary.find('tbody') count = 0 print for row in tables.findAll('tr'): for cell in row.findAll('td'): data = cell.getText() if (count < 15): data = data + ';' print data, count += 1 if (count==16): print data count = 0
Well, this is the code. I get 2 iterations of the loop loop before it tells me that the segmentation error ... :( In other words, I get to clear 2 url's of 6 that txt has.
Thanks in advance for your help
. Python ( ). BeautifulSoup:
for _ in range(3): r = Render('google.com')
, Render , :
Render
for _ in range(3): r = Render('google.com') del r
, , PyQt . PyQt, , . , , , .
, , , , , QApplication URL-. , .
QApplication
Source: https://habr.com/ru/post/1615754/More articles:GCM update from 7.5 to 8.3.0 fatal exception - androidPlay the framework against SocketIO, how to integrate them? - javaHow to delete multiple files at once using the Google Drive API - pythonRails link_to method with turbolinks disables formatting - ruby | fooobar.comHow to redefine the functionality of fields of base classes? - c #Loading a pyqt application causes a segmentation error several times - pythonClear multiple urls using QWebPage - pythonstd:: condition_variable:: wait с предикатом - c++UIPageViewController OR UIScrollView with paging Enabled = YES - iosКак написать очень большое число в xlsx через apache poi - javaAll Articles