I'm working on a project, which finds tutor jobs on a website after the user selects specific conditions(subject, wage, etc). The code does work successfully and shows the result on the console. But I want to display all the possible works on the GUI directly. Is there a function like get() or something that works? Thanks for helping.
I've tried the insert function to show all information on a blank but failed.
'''
def clickme():
usr_area = var_usr_area.get()
if usr_area == '全部':
usr_area = ''
sjt = var_sjt.get()
sly = var_sly.get()
if sly == '':
sly = 0
else:
sly = int(sly)
sdn = var_sdn.get()
if sdn == '全部':
sdn = ''
if sdn == '大專':
sdn = '專'
class Case():
def __init__(self, area, subject, student, wage, link):
self.area = area
self.subject = subject
self.student = student
self.wage = wage
self.link = link
def print_case(self):
print(self.area, self.subject, self.student, self.wage, self.link)
def master(self):
return '\n'.join([self.area, self.subject, self.student, self.wage, self.link])
class Information():
def __init__(self):
self.case = []
def add_case(self, new):
self.case.append(new)
def print_information(self):
for case in self.case:
case.print_case()
#1111人力銀行
def search_in_1111(count):#(to which page)
next_page = "https://tutor.1111.com.tw/case/caseSearch.asp?newSearch=search&Item1=2&skeyW=&sCity0Cht=&sCity0=&sDuty0Cht=科目&sDuty0="
for times in range(count):
content = requests.get(next_page)
if content.status_code == requests.codes.ok:
soup = BeautifulSoup(content.text, 'html.parser')
area = soup.select("div > ul > li:nth-child(1) > span.overflow")
subject = soup.select("span.col.col-md-35 > span.mobiContent")
student = soup.select("span.col.col-md-2 > span.mobiContent")
wage = soup.select("span.col.col-md-15 > span.mobiContent")
has_student = []
for i in range(len(area)):
link = soup.select("span.col.col-md-4 > span.mobiContent > a:nth-child(1)")[i]["href"]
link = "https://tutor.1111.com.tw/" + link
# fit = 0
# for school in sdn:
# if school in wage[i]:
# fit += 1
# if fit == 1:
# has_student.append(1)
# else:
# has_student.append(0)
if '~' in wage[i].string:
wageRange = wage[i].string.split('~')
else:
wageRange = [0, wage[i].string]
if (usr_area in area[i].string and sjt in subject[i].string and sly <= int(wageRange[1]) and sdn in student[i].string):
new_case = Case(area[i].string, subject[i].string, student[i].string, wage[i].string, link)
mix_information.add_case(new_case)
next_page = "https://tutor.1111.com.tw/" + soup.select("div > div.mobiHide > a:nth-child(8)")[0]["href"]
mix_information = Information()
search_in_1111(10)
search_in_104(10)
mix_information.print_information()