Answer the question
In order to leave comments, you need to log in
Why is data not being parsed from the local network, although the parsing works fine with the link to the site?
Hello, I'm a beginner in python'e and in general, in programming, please tell me why it's not possible to parse data using a link in the format http: //helpdesk.local.uralkali.com/maximo/ui/?event=loadapp&value=activity&uniqueid=397461&uisessionid =19831&csrftoken=qb7a7ob73gedm3h8erupgl2cec (there is a space in the link so that it does not shorten), but for a simple link, for example https://google.com/ , parsing works without errors. There are suggestions that the wrong libraries are being used, but I think it would be better to ask first. Test application code that was compiled to .exe and tested on a computer with a local network:
import sys
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QMainWindow, QLabel, QLineEdit, QPushButton, QListWidget, QMessageBox
from PyQt5.QtCore import QSize
from bs4 import BeautifulSoup
import urllib.request
def get_html(url):
response = urllib.request.urlopen(url)
return response.read()
def parse_nomobr(html):
global nomobr
soup = BeautifulSoup(html, 'html5lib')
for inp in soup.find_all('input', id='mx730'):
nomobr = inp.get('value')
def parse_nomzak(html):
global nomzak
soup = BeautifulSoup(html, 'html5lib')
for div in soup.find_all('div', id='mx385_holder'):
nomzak = div.label.text
def parse_datsoz(html):
global datsoz
soup = BeautifulSoup(html, 'html5lib')
for tit in soup.find_all('input', id='mx548'):
datsoz = tit.get('title').replace(u'Дата создания: ','')
def parse_krasro(html):
global krasro
soup = BeautifulSoup(html, 'html5lib')
for tit in soup.find_all('input', id='mx556'):
krasro = tit.get('title').replace(u'Крайний срок: ','')
def parse_danpol_opisan(html):
global danpol
global opisan
danpol = ''
soup = BeautifulSoup(html, 'html5lib')
table = soup.find('body', class_='tundra')
for tab in table.find_all('table', id='mx724'):
for tr in tab.find_all('tr')[3:14]:
for inp in tr.find_all('input'):
qwe = inp.get('value')
if danpol == '':
danpol = qwe
else:
danpol = '''\
{}
{}'''.format(danpol, qwe)
for tr in tab.find_all('tr')[15:16]:
for inp in tr.find_all('input'):
opisan = inp.get('value')
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setMinimumSize(QSize(300, 400))
self.setMaximumSize(QSize(300, 400))
self.setWindowTitle("TEST")
self.nameLabel = QLabel(self)
self.nameLabel.setText('Введите URL:')
self.line = QLineEdit(self)
self.listWidget = QListWidget(self)
self.button = QPushButton('ОК', self)
self.button.setShortcut('Return')
self.button.clicked.connect(self.on_click)
self.button.move(80, 60)
self.line.move(80, 20)
self.line.resize(200, 32)
self.nameLabel.move(10, 20)
self.listWidget.move(10, 100)
self.listWidget.resize(280, 270)
self.button.resize(200, 32)
def on_click(self):
if self.line.text() == '':
self.messagebox = QMessageBox.warning(self, 'Ошибка', "Ничего не введено!", QMessageBox.Ok)
else:
file = self.line.text()
parse_nomobr(get_html(file))
parse_nomzak(get_html(file))
parse_datsoz(get_html(file))
parse_krasro(get_html(file))
parse_danpol_opisan(get_html(file))
for dan in nomobr, nomzak, datsoz, krasro, danpol, opisan:
self.listWidget.addItem(dan)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
mainWin = MainWindow()
mainWin.show()
sys.exit( app.exec_() )
Answer the question
In order to leave comments, you need to log in
The URL that you described in the title - are you sending a request to it? Actually, through requests, this is done like this.
Moreover, the url here is http: //helpdesk.local.uralkali.com/
Where data contains data fields. In your case, here
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question