pysimplegui
import PySimpleGUI as sg
import requests
from bs4 import BeautifulSoup
class UrlClass:
element = []
@classmethod
def urlRequests(cls, url_parameter):
html = requests.get(url_parameter)
if html.status_code == 200:
bsobj_parameter = BeautifulSoup(html.text, "html.parser")
ul_ah_l = bsobj_parameter.select("ul.ah_l")
for i in ul_ah_l:
if 'data-list' in i.attrs:
for j in i.select("li.ah_item > a:nth-of-type(1)"):
tmp_dict = {"number":j.select_one("span.ah_r").string,
"doc":j.select_one("span.ah_k").string}
cls.element.append(tmp_dict)
return cls.element
class GUI:
@classmethod
def graphic(cls):
layout = [
[sg.Text("데이터 수집 대상 정보 입력", background_color="#a2e8f0", font=("Consolas", 18), justification="center")],
[sg.Text("url", size=(15, 1)), sg.InputText("url", key="_URL_")],
[sg.Button("DO crawling"), sg.Button("Exit")]
]
window = sg.Window("나의 첫 simpleGui").Layout(layout)
while True:
event, values = window.Read()
if event == "Exit":
break
elif event == "DO crawling":
print("values['_url_'] => {}\n".format(values['_URL_']))
sg.Popup('The values are', UrlClass.urlRequests(values['_URL_']))
window.Close()
GUI.graphic()
'언어 > python' 카테고리의 다른 글
data crawling (0) | 2019.03.03 |
---|---|
python + 지하철 + 이미지 (0) | 2019.02.24 |
python + crawling + elasticsearch (0) | 2019.02.04 |
프로젝트 코드 일부분 (0) | 2019.01.20 |
프로젝트 디렉토리 (0) | 2019.01.13 |