Python - PyCharm WebScrapping - ERROR Process finished with exit code -1073741819 (0xC0000005)

0

Can you help with this Project. My code is right but my for loop break in the second iteration, it should be 10 iterations. I try different options to solve this issue but none solve the problem.

import time
import bs4 as bs
import urllib.request
import sys
from PyQt5.QtWebEngineWidgets import QWebEnginePage
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QUrl


class Page(QWebEnginePage):
    def __init__(self, url):
        self.app = QApplication(sys.argv)
        QWebEnginePage.__init__(self)
        self.html = ''
        self.loadFinished.connect(self._on_load_finished)
        self.load(QUrl(url))
        self.app.exec_()

    def _on_load_finished(self):
        self.html = self.toHtml(self.Callable)
        print('Load finished')

    def Callable(self, html_str):
        self.html = html_str
        self.app.quit()


def main():
    A = [
        [1, "http://www.cambi.pe/", "soup.find_all('strong')[0].text", "soup.find_all('strong')[1].text"],
        [2, "https://www.rhaak.com/", "soup.find('label', {'id':'idFormPrincipal:j_idt20'}).text",
         "soup.find('label', {'id':'idFormPrincipal:j_idt17'}).text"],
        [3, "https://www.midpointfx.com/", "soup.find_all('span',{'style':'color:#FFFFFF;'})[4].text",
         "soup.find_all('span',{'style':'color:#FFFFFF;'})[5].text"],
        [4, "https://kambista.com/", "soup.find('strong',{'id':'valcompra'}).text",
         "soup.find('strong',{'id':'valventa'}).text"],
        [5, "https://www.cambiox.pe/", "soup.find_all('span',{'class':'bold'})[1].text[8:13]",
         "soup.find_all('span',{'class':'bold'})[1].text[-5:]"],
        [6, "https://www.chasquidolar.com/",
         "soup.find('div',{'class':'preciosHome','id':'preciosHome'}).text.strip()[13:18]",
         "soup.find('div',{'class':'preciosHome','id':'preciosHome'}).text.strip()[-5:]"],
        [7, "https://www.teloscambio.com/index.php", "soup.find('span',{'id':'compra'}).text",
         "soup.find('span',{'id':'venta'}).text"],
        [8, "https://www.assessorperu.com/", "soup.find_all('span')[11].text", "soup.find_all('span')[16].text"],
        [9, "https://www.acomo.com.pe/", "soup.find('span',{'id':'current_bid'}).text[3:9]",
         "soup.find('span',{'id':'current_bid'}).text[-6:]"],
        [10, "https://www.cyberchange.pe/", "soup.find('span',{'id':'fxrate_buy_text'}).text",
         "soup.find('span',{'id':'fxrate_sell_text'}).text"]

    ]

    for elem in A:
        page = Page(elem[1])
        soup = bs.BeautifulSoup(page.html, 'html.parser')
        compra = eval(elem[2])
        venta = eval(elem[3])
        print(compra, venta, sep="-")

if __name__ == '__main__': main()




My code only does two iterations and then break. It should be 10 iterations My output is:

C:\Python\python.exe C:/Users/OK/PycharmProjects/Prueba/PrimerPrograma.py
Load finished
3.536-3.556
Load finished
3.553-3.572

Process finished with exit code -1073741819 (0xC0000005)

One example of the answer is:

Load finished
3.536-3.556
Load finished
3.553-3.572
Load finished
3.534-3.540
Load finished
3.551-3.572
Load finished
3.526-3.576
Load finished
3.513-3.592
Load finished
3.521-3.512
Load finished
3.522-3.575
Load finished
3.511-3.519
Load finished
3.503-3.574

enter image description here

My characteristics are:

Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:01:55) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.

Thank you so much

python
pycharm
runtime-error
asked on Stack Overflow Sep 14, 2020 by Paul Martínez Llerena • edited Sep 16, 2020 by Paul Martínez Llerena

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0