Skip to content

Commit

Permalink
Merge pull request #3 from austinhuang0131/main
Browse files Browse the repository at this point in the history
Use GitHub Action to automatically update
  • Loading branch information
MakersMark3333 committed Apr 16, 2022
2 parents 130ae75 + 464d2dc commit 125b610
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 8 deletions.
Binary file removed .DS_Store
Binary file not shown.
31 changes: 31 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: instances-updater

on:
schedule:
- cron: '10 2 * * *'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: get repo content
uses: actions/checkout@v2

- name: setup python
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: install python packages
run: |
python -m pip install --upgrade pip
pip install html-table-parser-python3 pandas
- name: run script
run: python CrawlObject.py

- name: commit
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update scrape
commit_author: GitHub Actions <actions@github.com>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
33 changes: 25 additions & 8 deletions CrawlObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# pandas dataframe
import pandas as pd

import csv
import csv, os

class Shanghai_Help_Scraper:

Expand All @@ -38,24 +38,43 @@ def __scraper_content(self):
return f.read()

# Constructing the dataframe
def __df(self, total_page):
def __df(self, total_page, upto=-1):
n = 99999 # i most certainly hope we never reach this number.
rows = []
while self.__curr_page <= total_page:
while self.__curr_page <= total_page and n > upto:
xhtml = self.__scraper_content().decode('utf-8', errors='ignore')
p = HTMLTableParser()
p.feed(xhtml)
title = ['编号', '时间', '程度', '分类', '摘要', '地址', '详情']
for i in range(1, len(p.tables[0])):
n = int(p.tables[0][i][0])
if n <= upto:
break
rows.append(p.tables[0][i])
print(str(self.__curr_page) + "pages scraped!")
self.__curr_page += 1
df = pd.DataFrame(columns = title, data = rows)
return df

# Function call, users need to provide total_page
def get(self, total_page):
df = self.__df(total_page)
df.to_csv('shanghai.csv', encoding = 'gbk', errors='ignore')
# all=False: only adds new entries on the top; in this case total_page is maximum
def get(self, total_page, all=False):
if not all:
with open("shanghai.csv", "rb") as f:
f.readline() # discarded
l = f.readline()
n = int(l.decode("gbk").split(",")[1])
df = self.__df(total_page, n)
df.to_csv('shanghai_new.csv', encoding = 'gbk', errors='ignore')
with open ("shanghai_new.csv", "ab") as g:
while l:
g.write(l)
l = f.readline()
os.remove("shanghai.csv")
os.rename("shanghai_new.csv", "shanghai.csv")
else:
df = self.__df(total_page)
df.to_csv('shanghai.csv', encoding = 'gbk', errors='ignore')

def pages_scraped(self):
return self.__curr_page - 1
Expand All @@ -64,5 +83,3 @@ def pages_scraped(self):
test = Shanghai_Help_Scraper()
test.get(251)
print("Congratulations, you scraped " + str(test.pages_scraped()) + " pages!!")


57 changes: 57 additions & 0 deletions shanghai.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,61 @@
,���,ʱ��,�̶�,����,ժҪ,��ַ,����
0,4373,04-16 09:03:02,������,����,������˰��æ,������,�鿴 Close �������� ������ û��������Դ �Ѿ���ʳ2���� ÿ�쿿��ˮ�ȹ� ����Ҳ�������� �绰Ҳ��ͣ���� �ʾͺ����˰�æ�ȹ��ѹ� �պ�һ������ ֧����18963758148 ���ٶ������ڴ˹�л����� ϣ���������ս��� ��ϵ�ˣ������� ��ϵ�绰��13033049284
1,4372,04-16 08:59:55,������,����,ûǮ��,�ֶ�����,�鿴 Close �������� ��С��һ�����ˣ�ûǮ�� ��ϵ�ˣ��� ��ϵ�绰��15006726260
2,4371,04-16 08:59:33,����,����,��Ϣ����ָ��,������,�鿴 Close �������� �������п��㳡ij��˾ֵ����Ա���Ź��������ʿ�Ҫ�������䶳ˮ��ʳ���������ȷ���ʳ�� ��ϵ�ˣ������� ��ϵ�绰��13391360866
3,4370,04-16 08:59:28,����,����,���dzԵģ��õĿ�û�з��ˡ�,��ɽ��,�鿴 Close �������� ��ۣ���ˣ����࣬����ֽ ��ϵ�ˣ��ϼ ��ϵ�绰��15221008575
4,4368,04-16 08:56:03,������,�ز�,��Ҫ��ҩ,�ֶ�����,�鿴 Close �������� ���������˼�����ҩ ��ϵ�ˣ���ΰ�� ��ϵ�绰��13482250777
5,4367,04-16 08:55:24,������,�ز�,��ҩ,��ɽ��,"�鿴 Close �������� ����ͣҩһ���ˣ�������Ҫ��ҩ1.����ҩ����������Ƭ��8�� 2����Ѫѹҩ������ɳ̹�����ȵ�ƽƬ��5�У�����˸�Ѫѹû�еĻ����Ը�Ϊ���������
����ͣҩһ���ˣ�������Ҫ��ҩ1.����ҩ����������Ƭ��8�� 2����Ѫѹҩ������ɳ̹�����ȵ�ƽƬ��5�У�����˸�Ѫѹû�еĻ����Ը�Ϊ�������ҩ�
�Ѿ�ȷ����ұҽԺ�л���ҩ�� ��ϵ�ˣ����� ��ϵ�绰��13817117445"
6,4366,04-16 08:53:11,������,����,,������,�鿴 Close �������� �Ѿ�һ����û�й����ˣ�������Ҫ�����⣬ס�ڳ��ⷿ�99�IJ˰�����Ҳ�򲻵��ˣ������ʣ���׺͹����ˣ���û���ھ��ܹ������ǣ��ҵ�֧����15000700044�����ᣬ֧���������Լ������֣�ʵ���Ƶ� ��ϵ�ˣ����� ��ϵ�绰��15000700044
7,4365,04-16 08:51:39,������,�ز�,���񼲲�,������,"�鿴 Close �������� ������ҩ��µ�ƽ��5mg/СƬ/�Σ���10mg/��Ƭ/��
����������������һ�Σ�10mg/Ƭ/�Ρ����ٶ������������һ���¡���Ҫ���͡�лл ��ϵ�ˣ������� ��ϵ�绰��13916623205"
8,4362,04-16 08:43:25,������,����,��������ȱ,������,�鿴 Close �������� ����7O�������ˣ�������Ѫѹ�����򲡣��ټ��������������������������������С��ʧ����ƽʱ���� ������ �����]���ˣ���С����ذ���֮�ã������ͣ��ÿ��ÿʱҪ�� ������ ������ȱ��������������ˣ�־Ը����������һ�ѣ���ݡ� ��ϵ�ˣ������� ��ϵ�绰��13917433463
9,4360,04-16 08:42:14,������,����,��Ǹ�����������������Կ�һ����,�ζ���,�鿴 Close �������� ���ã�����һ����������������Ա��������Ϊ�����أ�����ʱû��������Դ�������ǽ���������ڣ�����û���㹻���ʽ���������㹻����Ǯ������������һ������IJ���Ҫ�ܶ࣬ʮԪ���ӡ�����ռ�ù�����Դ���������û�취�ˡ�֧�������Һ���ͬ�ţ����ϵ�ÿ���֣�ÿ�仰�Ҷ�Ը�⸺�������Ρ� ��ϵ�ˣ�ף���� ��ϵ�绰��19905811253
10,4359,04-16 08:39:04,������,����,���弲��,������,"�鿴 Close �������� ��ҪҩƷ
���ܿ�����ʯΤ���� ��ϵ�ˣ��� ��ϵ�绰��18720953801"
11,4358,04-16 08:36:21,������,����,��ַ������·������·��,�ֶ�����,�鿴 Close �������� ��ˮ����ס�˼���ʦ����ͨ ������û���� ��ϵ�ˣ��� ��ϵ�绰��13661948749
12,4357,04-16 08:36:20,������,�ز�,������˥��,�ֶ�����,�鿴 Close �������� ����˥�߽�������ҩƷ �����������׶�Ƭ ��ϵ�ˣ��·� ��ϵ�绰��13916732945
13,4356,04-16 08:36:17,������,����,�������֤,�ɽ���,�鿴 Close �������� ������֤ԭ����Ҫ���ɽ�����������Է�����ɽ��ʡ��̨�С������ݹ�˾���ɡ� ��ϵ�ˣ������ ��ϵ�绰��13817251301
14,4355,04-16 08:36:15,�ϼ�,����,��ɰ�ǡ�����,�ֶ�����,�鿴 Close �������� ��ɰ�ǡ��Ρ����͡����͡����� ��ϵ�ˣ������� ��ϵ�绰��13818957248
15,4354,04-16 08:35:53,������,����,5���������˴���,�ֶ�����,�鿴 Close �������� 5������3����δ�����ߣ������������Ի�Ͼ�ס ��ϵ�ˣ�ף���� ��ϵ�绰��13585802864
16,4353,04-16 08:35:49,������,����,ֻ����һ������,������,�鿴 Close �������� �Ⱦ����ǰɣ���������ʯ·1082Ū��ȪԷ�ӷ�յ�����ֻ����һ�����ʣ��������������������ܲ�����С��ţ�̣�5��Ѽ�ᣩ���ǰ�͵������������Ź��۸񷭼������ͻ���һ���ӳ٣�����Ҫ�ô�Ҷ����� ��ϵ�ˣ��� ��ϵ�绰��13918720380
17,4352,04-16 08:32:21,������,����,60��,�ɽ���,�鿴 Close �������� ����С����Ҫס�� ��ϵ�ˣ�����ʦ ��ϵ�绰��13361919856
18,4349,04-16 08:29:24,������,����,�ȾȺ���,��ɽ��,�鿴 Close �������� ���Ѿ������ˣ��ϰ岻������һ�����У������Ѿ�����10�����ˣ���ɽ���������ǹ�Ԣ�ͷ���һ�����ʣ��Ҹо��ҳŲ���ȥ�� ��ϵ�ˣ������� ��ϵ�绰��15800794592
19,4348,04-16 08:29:16,������,�ز�,�����Ҫ��������΢�ŵ绰ͬ��,������,�鿴 Close �������� �����Ҫ���������������ⷿ ��ǰ�ڸ��빺�������������� 3.9�� ��˾��һ���ϰ� 3.13������� ��3.22֮ǰ���ʶ����� ֮������� ������ˮ һ���ⶼû�Ե� �����������ʼ�ֱ�ٵĿ��� ���ҽ��յ�һ�� ����ĺ�����⣬�ܰ��������Ź�һ������ʳ���� ���ûǮ�� ���������Ҫ�������������� ��ϵ�ˣ��� ��ϵ�绰��17681925774
20,4347,04-16 08:27:12,������,����,������,��ɽ��,�鿴 Close �������� ���׷ƵĶ�����װ������L���100��Ƭ�������ṩ ��ϵ�ˣ���Ѽ� ��ϵ�绰��157****7441
21,4345,04-16 08:20:29,������,�ز�,�������Ժ���,������,�鿴 Close �������� ֱ������������Ҫ���ƣ�һ��С�����ḳ����룬�ڷο�ҽԺ������ҽԺ���ĺ��ᶼ�����ԣ������޷����̽�����ҽԺ���޷����� ��ϵ�ˣ���Ůʿ ��ϵ�绰��13956202223
22,4344,04-16 08:19:57,�ϼ�,����,����ֽ��㣬�ϻ�,�ֶ�����,�鿴 Close �������� ����ֽ��㣬X����Xl���ϻ������������򲻵�����������Ҫ����С�����˶�ƴ���� ��ϵ�ˣ�С���� ��ϵ�绰��15618975205
23,4343,04-16 08:19:31,����,����,ˮ����˺ö����ˣ�û��ֽ�ˣ�С������û���Ź��򲻵�,������,�鿴 Close �������� ����ֽ���ͣ����� ��ϵ�ˣ������� ��ϵ�绰��17521641029
24,4342,04-16 08:16:55,������,�ز�,������,������,�鿴 Close �������� �ֹ�ƽ̨�����Թ���20�����˼����������� ��ϵ�ˣ��� ��ϵ�绰��17521300489
25,4341,04-16 08:16:10,������,����,������ҩ,�����,�鿴 Close �������� ���˻�����֢������մ�����ҩ4�գ����ַ�����ʧ�ߣ�����˼ŵ˼�������� ��ϵ�ˣ�����ΰ ��ϵ�绰��13817975822
26,4340,04-16 08:14:27,������,����,�˵���Ԯ,�ɽ���,�鿴 Close �������� ȥ�����ʧҵ�������κ����룬���·����˷ݹ�������û������������˹�˾�������������ɶ��ҽ����˽�Ƹ��û���κξ��ò������������������·��⽻���𣬷���������գ����Э���޹�������������С���������ͷ��������˾�֧����137074795@qq.com���Σ�����������Ϣ���պ�ػ��� ��ϵ�ˣ������� ��ϵ�绰��18217625499
27,4339,04-16 08:12:26,�ϼ�,����,��Ҫ��������,������,�鿴 Close �������� �߲ˣ����ף��棬����ֽ����ֽ�������� ��ϵ�ˣ���Ůʿ ��ϵ�绰��13816093740
28,4338,04-16 08:11:03,������,�ز�,�Ľ�ʹ,������,�鿴 Close �������� ��ҩ�Ѿ�һ�ܡ������ֿ�47.5mg����ɳ̹���ȵ�ƽƬ��ÿ���һ��������ҩ����Ҫ30����һ���µ������� ��ϵ�ˣ������� ��ϵ�绰��13816319686
29,4336,04-16 08:08:00,�ϼ�,����,����Ӫ��ȱ��֢,������,�鿴 Close �������� ���ల���̷� ��ϵ�ˣ������� ��ϵ�绰��15821103565
30,4334,04-16 08:04:19,�ϼ�,����,���Ŀ��԰�����,�ζ���,�鿴 Close �������� ��԰���и��������� ��ϵ�ˣ��� ��ϵ�绰��15553921774
31,4333,04-16 07:57:48,������,�ز�,����Ҫ,�ֶ�����,�鿴 Close �������� ������ʪ�ͺ���Ƭ ��ϵ�ˣ���Ůʿ ��ϵ�绰��13764900867
32,4332,04-16 07:57:35,������,�ز�,�������򲡲���,�����,"�鿴 Close �������� ҩƷ��1: �����ᰢ����͡Ƭ
2:��ǰ������Ƭ ��ϵ�ˣ���ӱ ��ϵ�绰��13651616892"
33,4331,04-16 07:52:49,������,����,ŧ�׻�ҩ����,��ɽ��,"�鿴 Close �������� �򸹲�ŧ�ף���4-13���޵�ҽԺ����ŧ���г�������������4-14
4-15�ս��л�ҩ������4-16���޵�ҽԺ��Ϊ����ҽԺ���޷������ż���ֱ�ɽ���޷���ϵ���������ҽԺ���޷����л�ҩ�������ѳ���ŧѪ�޷����������軻ҩ��������ҪѰ�ҿ��ż���ҽԺ�����߱�ɽ����������ҽ����Ա���л�ҩ�������г��� ��ϵ�ˣ������� ��ϵ�绰��13052023325"
34,4329,04-16 07:39:56,����,����,��Ϊ���飬����ĵط������ˣ���ҩˮҩ��Ҳû�У���,������,�鿴 Close �������� Ok��ʹ�õ�˫��ˮ���漱 ��ϵ�ˣ���С�� ��ϵ�绰��13817620617
35,4327,04-16 07:37:45,������,�ز�,��֢תԺ,�ֶ�����,�鿴 Close �������� ���Ʋ��˷λ�ˮ����תԺ���� ��ϵ�ˣ���� ��ϵ�绰��18301734353
36,4326,04-16 07:34:58,������,����,��������赼,�ֶ�����,�鿴 Close �������� רҵ�����赼���ṩ�����ڼ䣬���ﻥ����V��13585548781 ��ϵ�ˣ������� ��ϵ�绰��13585548781
37,4325,04-16 07:29:31,������,�ز�,Ҫ�߲�����,,�鿴 Close �������� ��֢���ڲ��ˣ�����û���߲ˣ�����Ҳ�������߲ˣ�ϣ���ܰ�æ��һ���߲ˡ�лл�� ��ϵ�ˣ������� ��ϵ�绰��13818029700
38,4324,04-16 07:24:41,������,����,������ʪ,�����,�鿴 Close �������� ������ʪL�ţ����� ��ϵ�ˣ�����ƽ ��ϵ�绰��13601612750
39,4322,04-16 07:14:33,������,����,���̡�ҩ���߲ˡ�����,������,�鿴 Close �������� ��æ��ҩ����ˡ��ɹ����ʣ�����ÿ���г�ȥ�Ϻ���13862155938΢ͬ�� ��ϵ�ˣ������� ��ϵ�绰��13776195696
40,4321,04-16 07:14:00,�ϼ�,����,��app���������ˣ�����ס����ҵ��������Ҳû�����ʡ��к������ܰ�æ�ṩ���������𡣸ж�,������,�鿴 Close �������� ��Ҫ�����ţ�̡� ��ϵ�ˣ���Ůʿ ��ϵ�绰��18487369386
41,4320,04-16 07:13:43,������,����,86�����˶�������ҩ��ʳ��,������,�鿴 Close �������� 86�����˼��裺һ��ҩƷ��1����ˮ�ɼ� 2���������� ����ʳƷ���ס��߲ˡ�ˮ�������ࣩ ��ϵ�ˣ������� ��ϵ�绰��13905185111
42,4319,04-16 07:12:51,������,����,���������ް׽��1���̷�,������,�鿴 Close �������� ���谮�������ް�׽�1���̷� ����������� ��ϵ�ˣ��˳� ��ϵ�绰��15821991046
43,4318,04-16 07:08:04,����,����,�����Կ��Գźܾ�,,�鿴 Close �������� �ڿ��� ��ţ�� ��Ҫ�������������һ���ܶ��� ����� ��ϵ�ˣ��� ��ϵ�绰��18512199097
44,4317,04-16 07:03:15,������,����,������ʪ,������,�鿴 Close �������� �׶���ʪ2xl-3xl ��ϵ�ˣ������� ��ϵ�绰��18121295808
45,4316,04-16 06:58:22,������,����,���Բ��Ѷ�ҩ,�����,"�鿴 Close �������� ���Բ��˼����Ѫѹҩ�
����ɳ̹�������Ƭ4��
����Ƭ2�� ��ϵ�ˣ���Ңٻ ��ϵ�绰��13585763310"
46,4315,04-16 06:50:54,������,����,����·2688��ʢС����ҾƵ�312����,������,�鿴 Close �������� ����Ҫ�߲����ʣ��������Σ��ó�ʱ��û�Ա����ˣ�����֧Ԯһ�£���ȻΣ���ˣ�����Ҫ�߲��������δ��� ��ϵ�ˣ������� ��ϵ�绰��15026878590
47,4314,04-16 06:47:16,������,����,��ʢС����ҾƵ�312����,������,�鿴 Close �������� ����Ҫ���ʣ���Ҫ�������Σ��ó�ʱ��û�Թ������� ��ϵ�ˣ������� ��ϵ�绰��18621845187
48,4313,04-16 06:46:37,������,����,������7�ſ�ʼ������ ��ʪ��û���ˣ�����ÿ������޳������а������ṩ��лл,������,�鿴 Close �������� ��ʪ2xl ��ϵ�ˣ�����ʦ ��ϵ�绰��15601753827
0,4312,04-16 06:34:33,������,����,������ʳ,�����,�鿴 Close �������� ���ף�˭�����д��ף�������ʳ����ۣ�����΢�źţ�there0908 ��ϵ�ˣ���Ůʿ ��ϵ�绰��15836493309
1,4311,04-16 06:26:55,�ϼ�,����,��Ҳ�������˰�55555�ṩ��������赼,�ֶ�����,�鿴 Close �������� �ṩ���������ѯ�赼(��Ҳ��������555555 ��ϵ�ˣ����� ��ϵ�绰��133****1530
2,4310,04-16 06:22:50,������,�ز�,�����䵽,��ɽ��,�鿴 Close �������� µ�������ϻ��� ��ϵ�ˣ������� ��ϵ�绰��13801969327
Expand Down

0 comments on commit 125b610

Please sign in to comment.