데이터 스크랩(Data scraping)

One-liner (명령어 한꺼번에 입력하기)

페이지를 다운로드 하고, 추출하고, json으로 변환해서 다시 추출하고 하는 과정을 한줄의 명령으로 한번에 실행할수 있습니다. 파이프( | ) 기호를 써서 중간 결과물 없이 최종 csv 파일 하나만 생성됩니다.

curl -s 'https://projecteuler.net/archives' \
| scrape -be 'table#problems_table > tr:not(:first-child)' \
| xml2json \
| jq -c '.html.body.tr[] | {id:.td[0]."$t", title:.td[1]."a"."$t"}' \
| json2csv -k id,subject,solved > test_list.csv

 

댓글

댓글 본문
graphittie 자세히 보기