Skip to content
조회 수 1625 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

파이썬 한우정액 정보 스프레드로 추출하기

 

 

 

 

import time
from unicodedata import lookup #time 명령어 사용하기 
from bs4 import BeautifulSoup # BeautifulSoup 불러오기






 
#파이썬 requests 모듈은 간편한 HTTP 요청처리를 위해 사용하는 모듈로 별도로 설치해 주어야 한다.
import requests #pip3 install requests
 
#정액사이트 http://www.limc.co.kr/KpnInfo/KpnDetail.asp?KpnNo=1146%20&chk=B&cKPNno=
group = '1그룹'
search_data = '1243'
 
url = "http://www.limc.co.kr/KpnInfo/KpnDetail.asp?KpnNo=" + search_data + "%20&chk=B&cKPNno="
html = requests.get(url)
bs_html = BeautifulSoup(html.content,"html.parser")
 
#체형정보
form = bs_html.select("table.t07 tr")[2]
sirloin = form.select("td")[2].text
print(sirloin#등심값
 
form = bs_html.select("table.t07 tr")[12]
ht = form.select("td")[2].text
print(ht#체고
 
form = bs_html.select("table.t07 tr")[14]
lh = form.select("td")[2].text
print(lh#체장
 
#유전능력
form = bs_html.select("table.t06 tr")[1]
cold_wt1 = form.select("td")[0].text #냉도체중EPD
bcjg1 = form.select("td")[1].text #배최장근단면도EPD
bk_fat1 = form.select("td")[2].text #등지방두께EPD
ir_fat1 = form.select("td")[3].text #근내지방도EPD
 
form = bs_html.select("table.t06 tr")[2]
cold_wt2 = form.select("td")[0].text #냉도체중Acc
bcjg2 = form.select("td")[1].text #배최장근단면도Acc
bk_fat2 = form.select("td")[2].text #등지방두께Acc
ir_fat2 = form.select("td")[3].text #근내지방도Acc


 
#결과값 스프레드로 전달하기
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = [
'https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive',
]
json_file_name = 'C:\\Users\\크리스퍼\\python_code\\JSON주소.json'
credentials = ServiceAccountCredentials.from_json_keyfile_name(json_file_namescope)
gc = gspread.authorize(credentials)
spreadsheet_url = '파일주소'
# 스프레스시트 문서 가져오기 
doc = gc.open_by_url(spreadsheet_url)
# 시트 선택하기
worksheet = doc.worksheet('정액')
 
#print(now + " ||| " + eps + " ||| " + bps + " ||| " + per + " ||| " + upper + " ||| " + pbr + " ||| " + allocation)
worksheet.insert_row([groupsearch_datasirloinhtlhcold_wt1bcjg1bk_fat1ir_fat1cold_wt2bcjg2bk_fat2ir_fat2], 3)

 

 

스프레드시트로 전송한 결과 이미지

휴지통.png

 

로그인 후 댓글쓰기가 가능합니다.

?

List of Articles
번호 분류 제목 날짜 조회 수
897 AutoHotKey ahk) Send an email 메일발송하기 2018.01.17 9390
896 AutoHotKey AHK) 보안프로그램 등으로 화면복사(Printscreen) 안될때 사용방법 1 12 file 2012.11.21 47166
895 AutoHotKey ahk) 열려진 엑셀창의 값 불러오기 1 2013.10.30 32529
894 AutoHotKey ahk) 오토핫키 콤보박스 제어하기 file 2013.10.30 38180
893 AutoHotKey Ahk) 웹페이지 감시결과에 따라 마이피플로 글 전송하기 12 file 2013.01.06 44023
892 AutoHotKey ahk_l 웹페이지 앞, 뒤페이지 제어 예제소스 및 설명첨부 2011.02.22 17535
891 AutoHotKey ahk_l 과 com 의 이해 2011.02.22 17485
890 AutoHotKey AHK_L 예제소스 1 2011.02.10 17015
889 AutoHotKey ahk_l 웹페이지 파일로 저장한 뒤 불러와 필요한 부분 추출하여 출력하기 2011.02.22 16992
888 컴퓨터잡담 AHK_L) SysListView321 컨트롤 내용 추출하기 2011.10.07 9893
887 AutoHotKey ahk로 만든 파일을 exe로 컴파일 한 후 실행시킬때 변수를 임의 1 1 2011.02.24 15333
886 AutoHotKey AHK에서 가능한 COM 인터넷 익스플로러 및 GUI 브라우저 1 2011.02.11 19502
885 AutoHotKey ahk와 ahk_l 의 웹페이지 로딩완료 체크 비교 3 2011.02.11 20324
884 컴퓨터잡담 ajax의 XMLHttpRequest 객체 1 2010.03.27 7463
883 WindowsTip An error [-5001 : 0x80070002] ha occurred while running the setup 오류 해결방법 file 2013.06.14 21936
882 Server Apache & Mysql 셋팅방법(httpd-mpm.conf / my.ini) 2013.05.13 13707
881 Server APACHE PHP 에러 잡기 1 2016.03.23 9962
880 Server Apache에 대한 mod_proxy 지원 구성 2016.09.06 1801
879 컴퓨터잡담 API Hooking 유저 레벨 루트킷 1 2010.01.21 11623
878 Server APMSETUP7 PHP 업그레이드 2015.06.02 6373
Board Pagination Prev 1 2 3 4 5 ... 46 Next
/ 46

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소