- ©«¤l
- 109
- ¥DÃD
- 1
- ºëµØ
- 0
- ¿n¤À
- 116
- ÂI¦W
- 0
- §@·~¨t²Î
- win7
- ³nÅ骩¥»
- 2007
- ¾\ŪÅv
- 20
- µù¥U®É¶¡
- 2016-8-4
- ³Ì«áµn¿ý
- 2018-10-22
|
«e´X¤Ñc¤j¦^ÂЪº®ÉÔ¦³¶K¤Fvbaªºcode¡AÅý§Ú·Q¨ì¦pªG§ä¤@¨Ç¦bexcelª©ªº°ÝÃD¥Îpython¸Õ°µ¬Ý¬Ý¡A¤]³\¦³¿³½ìªºªB¤Í¥i¥H¬Û¤¬°Ñ·Ó¡C
§ì¸ê®Æ«Ü¦h°ÝÃD·Q°_¨Ó¤£§xÃø¡A¦ý¹³§Ú³£¥u°µÂ²³æªºÀ³¥Î¡A¸gÅ禳¡A¯un°µ¤ñ¸û§¹¾ãªº¸ê®Æª¦¨ú¡A¼²À𪺲Ӹ`°ÝÃD·Q¥²«D±`¦h¡C
³Ìªñ¤ñ¸û¦³®É¶¡¡Aè¦n¶X³oÓ¾÷·|½m²ß¤@¤U¡CÅwªïª©¤WªºªB¤Í¤@°_¬ã¨s°Q½×¡A¦pªG¦³¨ä¥L¨Ï¥Îpythonªº«e½ú¡A¤]½Ð¤£§[µ¹§Ú¤@¨Ç´£ÂI¸ò«Øij¡C
¤@¶}©l§Ú·Q´N±q³o½g¶}©lhttp://forum.twbts.com/thread-18259-1-2.html¡C
GBKEEª©¤j¤w¸g¥Îvba´£¨Ñ¤F«Ü¦nªº¸Ñ¨M¤è®×¡A¦ýY¬O·Q´«Ó¤f¨ýÁÙ¬O¥i¥H¥Îpython¸Õ¸Õ¬Ý§â¸ê®Æª¦¨ú¤U¨Ó¡C
ºô§}ºô§}¡Ghttp://church.oursweb.net/slocation.php?w=1&c=TW&a=&t=&p=
ºô¶¬Ý°_¨Ó¨S¦³¤°»ò©_©_©Ç©Çªºjavascript¡A¦pªG¥u¬On§ì¹Ï¤ù¤¤ªºÂ²©ö¸ê®Æ¡A¨º¥un¡G- #·Ç³Æ¤u¨ã
- import requests
- from bs4 import BeautifulSoup
- #«Ø¥ß¤@Ósession
- s = requests.session()
- for i in range(11,14):
- #ºô§}Åܰʪº¥u¦³³Ì«á¤@ӼƦr¡A¦@286¶¡A¥Îrange(1,287)´N¥i¥H§â©Ò¦³¼Æ¦r¶]¹L¤@¦¸
- #´ú¸Õ®É½Ð¤£n¶]¤Ó¦h¶¡A¥Î(1,3)¡B(11,14)¡B(280,283)¤§Ãþªº´N¦n
- url = 'http://church.oursweb.net/slocation.php?w=1&c=TW&a=&t=&p=' + str(i)
- res = s.get(url)
- #Y¦¬¨ìªºres¤å¦r¬°¶Ã½X´N¥[Óencoding
- res.encoding = 'utf-8'
- soup = BeautifulSoup(res.text, 'lxml')
-
- #¨ú±o¸ê®Æ¡A§ÚÌnªº¸ê®Æ³£¦s¦b³o¨âºØtr¸Ì
- data = soup.find_all('tr',['tb__a', 'tb__b'])
- #±N¸ê®Æ¦L¥X
- for d in data:
- print(d.text)
-
- i += 1
½Æ»s¥N½X ¨º¦pªGn¦¬¶°¸Ô²Ó¸ê®Æ©O¡H¨º´Nn¨ú±o¨C¶¸Ìªº¦Uӱз|ªº³sµ²¡A¤@Ó¤@Ó¶i¥hª¦¨ú¡C |
|