Skip to content

Commit

Permalink
영재관, kbo 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
statKim committed Jan 17, 2019
1 parent ebdc57a commit dda8447
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 222 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.c9/
.c9/
.git/
297 changes: 121 additions & 176 deletions app.py

Large diffs are not rendered by default.

37 changes: 0 additions & 37 deletions df_to_image.py

This file was deleted.

Binary file removed mytable.png
Binary file not shown.
30 changes: 30 additions & 0 deletions requirments.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
BzrTools==2.6.0
SecretStorage==2.0.0
argparse==1.2.1
bzr==2.7.0dev1
chardet==2.0.1
colorama==0.2.5
configobj==4.7.2
duplicity==0.6.23
html5lib==0.999
httplib2==0.8
keyring==3.5
launchpadlib==1.10.2
lazr.restfulclient==0.13.3
lazr.uri==1.0.3
lockfile==0.8
mercurial==2.8.2
oauth==1.0.1
paramiko==1.10.1
pycrypto==2.6.1
pygobject==3.12.0
pygpgme==0.3
python-apt==0.9.3.5ubuntu2
requests==2.2.1
simplejson==3.3.1
six==1.5.2
urllib3==1.7.1
wadllib==1.3.2
wheel==0.24.0
wsgiref==0.1.2
zope.interface==4.0.5
88 changes: 80 additions & 8 deletions test2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,94 @@
from bs4 import BeautifulSoup
import random

url = "http://www.statiz.co.kr/league.php?opt=2018"
url = "https://sports.news.naver.com/kbaseball/schedule/index.nhn"
req = requests.get(url).text
doc = BeautifulSoup(req, "html.parser")

#print(doc)
# print(len(doc.select("#todaySchedule > li")[0]))

test = "★ 2018 KBO리그 팀순위\n\n순위 │ 팀 │ 경기 │ 승 │ 패 │ 무 │ 게임차 │ 승률\n"
for team in range(1,11,1):
x = doc.select("table.table.table-striped > tr")[team]
for i in range(0,8,1):
test = test + x.select("td")[i].text + " │ "
if i == 7:
test = test[:-3] + "\n"
test = []
x = doc.select("#todaySchedule > li")
for i in range(len(x)):
test.append(x[i].select("div.cancel"))
if len(test[i]) == 0:
print("ㅋㅋ")
print(test)

# print(doc.select("#todaySchedule > li.before_game.last.before_game > div.cancel")[0].text)
# x = doc.select("#todaySchedule > li.before_game.last.before_game > div.cancel")[0].text
# if "취소" in x:
# print("굿")

# if len(away) != 0:
# game_status = doc.select("em.state")
# for i in range(len(away)): # away 즉, 오늘의 경기 개수
# if "취소" in cancel[i].text:
# test = test + stadium[home[i].text] + " (우천취소)\n" + away[i].text + "\t:\t" + home[i].text + "\n\n"
# else:
# if home[i].text in stadium:
# test = test + stadium[home[i].text] + " (" + game_status[i].text.strip() + ")\n" + away[i].text + "\t" + away_score[i].text + "\t:\t" + home_score[i].text + "\t" + home[i].text + "\n\n"
# return_msg = test[:-2]

# info = [[],[],[],[],[],[],[],[]]
# test = "★ 2018 KBO리그 팀순위\n\n순위\t|\t팀\t|\t경기\t|\t승\t|\t패\t|\t무\t|\t게임차\t|\t승률\n"
# for team in range(1,11,1):
# x = doc.select("table.table.table-striped > tr")[team]
# for i in range(0,8,1):
# info[i].append(x.select("td")[i].text)
# if i == 7:
# test = test[:-3] + "\n"


# import pandas as pd
# import numpy as np
# import matplotlib.pyplot as plt
# import six

# df = pd.DataFrame()
# df['순위'] = info[0]
# df['팀'] = info[1]
# df['경기'] = info[2]
# df['승'] = info[3]
# df['패'] = info[4]
# df['무'] = info[5]
# df['게임차'] = info[6]
# df['승률'] = info[7]
# print(df)
# print(doc.select("#_tab_box_kbo > div > ul > li > div.vs_list.vs_list2 > div > div")[0].text.strip())


# away = doc.select("#todaySchedule > li > div.vs_lft > p > strong")
# home = doc.select("#todaySchedule > li > div.vs_rgt > p > strong")
# away_pit = doc.select("#todaySchedule > li > div.vs_lft > p > span > a")
# home_pit = doc.select("#todaySchedule > li > div.vs_rgt > p > span > a")

# test = ""
# for i in range(5):
# test = test + away[i].text + "\t\tVS\t\t" + home[i].text + "\n" + away_pit[i].text + "\t\tVS\t\t" + home_pit[i].text + "\n\n"

# print(test)



#print(doc.select("#mainContents > div.module-wrapper > table.table.table-list.table-bordered.table-week > tbody > tr > td > p.menu"))
#print(doc.find("span"))
# x = doc.select("div.badge")[0].text


# test = "순위\t팀\tG\t승\t패\t무\t승차\t승률\n"
# for team in range(1,11,1):
# x = doc.select("table.table.table-striped > tr")[team]
# # x = x.select("td")[1].text
# for i in range(0,8,1):
# test = test + x.select("td")[i].text + "\t"
# if i == 7:
# test = test + "\n"
# print(test)
# print(len(x))


# title_tag = doc.select("dt.tit > a")
# star_tag = doc.select("div.star_t1 > a > span.num")
# reserve_tag = doc.select("div.star_t1.b_star > span.num")
Expand Down
16 changes: 16 additions & 0 deletions test3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import requests
from bs4 import BeautifulSoup
import random

url = "https://sports.news.naver.com/kbaseball/schedule/index.nhn"
req = requests.get(url).text
doc = BeautifulSoup(req, "html.parser")

print( doc.select("div.sch_score > ul.tab > li.on > a > em")[0].text.split(".") )

import time
print( str(time.localtime().tm_mon), str(time.localtime().tm_mday) )

today = doc.select("div.sch_score > ul.tab > li.on > a > em")[0].text.split(".")
if int(today[0])==time.localtime().tm_mon and int(today[1])==time.localtime().tm_mday:
print("ㄱㄱ")
15 changes: 15 additions & 0 deletions test4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import requests
from bs4 import BeautifulSoup
import random
import time

url = "http://www.statiz.co.kr/league.php?opt=" + str(time.localtime().tm_year)
req = requests.get(url).text
doc = BeautifulSoup(req, "html.parser")

ranking = doc.select("table.table.table-striped > tr")
print( doc.select("table.table.table-striped > tr")[1] )
if "div" in str(ranking[1]):
print("ㄱㄱ")
else:
print("ㄴㄴ")

0 comments on commit dda8447

Please sign in to comment.