ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[­ì³Ð] python¤W¥«Âd¤T¤jªk¤H¶R½æ¶W¤é³ø¸ê®Æ¤U¸ü

¦^´_ 140# lpk187

¨ä¹ê   ¤p§Ì´N¬O¸Ë Anaconda µM«á¨Ï¥Î 2.7
«Ü¦h®M¥óÁÙ¬O¤p§Ì¦b¸É¤Wªº@@

©Ò¥H¡A¥Ø«e§Ú¸I¤Wªº±¡ªp¡A¥t¥~¥Î  Anaconda ¶}¤@­Ó3.4ª©¥»¡A¥Î¤j®aªº¥N½X  ¤]³\´N¸Ñ¨M¤F?

TOP

¦^´_ 141# koshi0413


    ¨ä¹ê¤]¤£¥Î¤U¸ü3.xª©ªºAnaconda
¦b¦w¸Ë¥Ø¿ý¤U\Anaconda3\Scripts .....§ä¬Ý¬Ý¦³¨S¦³ 2to3 ©Î 3to2 ªºÀɮסA³o¬O2.xª©Âà3.xª© ¥H¤Î3.xÂà2.xª© ÀÉ®×
¥H§Úª©¥»¨Ó»¡¥u¦³ 2to3¡A¦Ó¥B¬O°õ¦æÀÉ exe ÀÉ¡A

TOP

¦^´_ 141# koshi0413

§Ú¥ý»¡©ú¤U¸ü 3to2
¦bcmd ¤U  cd C:\Anaconda3\Scripts <<³o¬O§Ú¦w¸Ëªº¥Ø¿ý¡AÀ³¥H§A¦w¸Ëªº¥Ø¿ý¬°·Ç
pip instsll 3to2

C:\Anaconda3\Scripts>pip install 3to2
Collecting 3to2
  Using cached 3to2-1.1.1.zip
Building wheels for collected packages: 3to2
  Running setup.py bdist_wheel for 3to2 ... done
  Stored in directory: C:\Users\lpk187\AppData\Local\pip\Cache\wheels\09\f6\6b\5220ff649a6eb703d0a1d55123ca5c6ccf5213a6bb87ddb806
Successfully built 3to2
Installing collected packages: 3to2
Successfully installed 3to2-1.1.1

³o¼Ë´Nªí¥Ü¦w¸Ë§¹¦¨
±µµÛ¦bC:\Anaconda3\Scripts¥Ø¿ý¤U²£¥Í¤@­ÓÀɮסA ¨S¦³°ÆÀɦWªº3to2¡A
§ó§ï¥¦ªº°ÆÀɦW¬°3to2.py
¦A¨Ó´N¬OÂà´«¤F
°²³]¦³­Ó py¬O¥H3ª©®æ¦¡¼gªº©ñ¦bD:\ ¤U¡AÀɦW¬° tt.py
C:\Anaconda3\Scripts>python 3to2.py -w d:\tt.py
...
...
RefactoringTool: Files that were modified:
RefactoringTool: d:\tt.py
³o¼Ë´Nªí¥ÜÂà´«¦¨¥\¤F

¦A¨Ó¬O2to3¥H§Úªºª©¥»¨Ó»¡¬O°õ¦æÀÉ2to3.exe¡A¤]¦]¬°¬O°õ¦æÀÉ©Ò¥H¾Þ§@·|²©ö³\¦h
¥H­è¤~¨º­ÓÀɮ׬°¨Ò
C:\Anaconda3\Scripts>2to3 -w d:\tt.py
...
...
RefactoringTool: Files that were modified:
RefactoringTool: d:\tt.py
³o¼Ë´Nªí¥ÜÂà´«¦¨¥\¤F

TOP

¤U­±¹Ï¤ù¬OÂà´««áªº®t²§

TOP

¦^´_ 144# lpk187


  ­ì¨Ó¦³ª©¥»Âà´«®M¥ó¡A·PÁ±z¤F¡E¡E¡E¡E¦³ªÅ·|¨Ó¸Õ¸Õ

¥t¥~¡A¤j®a´£¨úºô­¶¸ê®Æ®É¡A¦bºô¤W¦³¬d¨ì¡A´£¨ì¦³¨Çºô¯¸·|°O¿ý headers = {"User-Agent": "Mozilla/5.0"} ¸ê°T¨Ó§PÂ_³s½u°O¿ý¡]¦³¨Ç¬O§Pip¡^
¬°¤F¤£Åý´£¨úªººô­¶³o»ò§Ö´N§ïª©&¦³©Òĵı¡A©Ò¥H¤Wºô¬d¤F¨Ç¶Ã¼Æ±Æ¦Cªº¤è¦¡¡Aµ¹¤j®a¤è«K¨Ï¥Î
¶µ¥Ø¥i¥H¦Û¤v¤Wºô§ä¨Ó·s¼W¡A¥»¨­¬O¥´ºâ§ä¤Q­Ó¨Ó¥Î@@
  1. import random
  2. hs = random.choice([
  3. 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36',
  4. 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16',
  5. 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10'        
  6. ])
  7. headers = {"User-Agent":hs}
  8. print headers
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ jackyq ©ó 2016-9-16 17:08 ½s¿è

¦^´_ 145# koshi0413

Æ[¹î±Ó²¤³á
ÃÒ¥æ©Ò±`±`¦b¨º§ïª©
8,9¦¨À³¸Ó´N¬O³o­Ó­ì¦]
¤§«e¦³¤H¦b¨º©ñ¨é°Ó¶R½æ¤é³øªí¦Û°Ê§ì§ì¼Öªºµ{¦¡ , ¦³¤HÁÙ´²§G¸ê®Æ
¶R½æ¤é³øªí´N³Q§ï¦¨­nÅçÃÒ½X¾÷¨î
ÁÙ³Q¥[µùĵ»y: ¤£¥i´²§G

TOP

¦^´_ 146# jackyq

¦]¬°µu®É¶¡­«Âж}ºô­¶µ¥©ó¬O§ðÀ»¹ï¤èªº¦øªA¾¹¡A©Ò¥H¦³¨Ç·|§PÂ_ ip
¸ÑÂê©wip¤ñ¸û³Â·Ð@@
­n§ä¤@°ïip¡A³t«×¤S¤£Ã­¡A¦³¨Ç¥¢±Ñ²v°ª¡A¤p§ÌÃi¤F   «¢«¢

©Ò¥H¦³¨Ç¼g¥X¨Óªº  ³£«Ü§C½Õªº~~
¦]¬°¤@¶}©ñ¡Aºô­¶´NGG¤F@@

TOP

¥»©«³Ì«á¥Ñ koshi0413 ©ó 2016-9-17 19:51 ½s¿è

§ï¤@¤UÀH¾÷¿ï¨ú¤§§@ªk
  1. import random
  2. hs = ['Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36',
  3.        'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16',
  4.        'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0',           
  5.        'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0)',
  6.        'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)']

  7. headers = {"User-Agent":random.choice(hs)}   #¦¹¦æ½Ð¥á¦b¦Uºô­¶url«e¬q¡A¨C¦¸for¦Üºô§}´N·|ÅÜ´«¤F
½Æ»s¥N½X

TOP

¦^´_ 148# koshi0413
¯à§_¥H¦¹¤èªkÁ|¤@¨â­Ó½d¨Ò¡A
¤è«K©úÁA¨ä¹ê»Úºô­¶ªºÀ³¥Î¡H
ÁÂÁ¡I

TOP

¥»©«³Ì«á¥Ñ koshi0413 ©ó 2016-9-18 18:40 ½s¿è

¦^´_ 149# c_c_lai

®t§O¦b©ó  User-Agent  ¤º®e ·|ÀH¾÷ÅÜ´«¡AÁקK¥Î¦P¤@¸ê°T¤j¶q´£¨úºô­¶¡A¤U­±¦³win10, iphone, ipad,Linux
¨ä¥¦ªº­n¦bºô¤W¦¬¶°¡A¤Ï¥¿´N¬O¬Ý¨ì´N¥á¶i¥h¡AÀH¾÷ªº¶V¦h¶V¦n¡A¦bµu®É¶¡¤j¶q¨úºô­¶¡A°e¥X¦Ü¹ï¤è¦øªA¾¹ªº¸ê®Æ¤~¦³©Ò®t§O

¤£¹L³o¥u¬O²Ä¤@¨B¡A¨ä¹ê­«­nªºÁÙ¬O¦b©ó  ip ÀH¾÷ÅÜ´«

À³¥Î¨Ò¡G
  1. import requests
  2. import random

  3. hs = ['Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36',
  4.            'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16',
  5.            'Mozilla/5.0 (Linux; U; Android 4.1.2; zh-tw; GT-I9300 Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30',
  6.            'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10'     
  7.            'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)']


  8. headers = {"User-Agent":random.choice(hs)}
  9. url = '²Ä¤@­Óºô­¶'  
  10. payload={'download':'csv',
  11.         'qdate':'105/09/07',
  12.         'selectType':'ALL'}
  13. res = requests.post(url, headers=headers, data=payload, stream=True)

  14. headers2 =  {"User-Agent":random.choice(hs)}
  15. url2 = '²Ä¤G­Óºô­¶'
  16. payload2={'download':'csv',
  17.         'qdate':'105/09/07',
  18.         'selectType':'ALL'}
  19. res2 = requests.post(url2, headers=headers2, data=payload2, stream=True)
½Æ»s¥N½X
³æ¯ÂªºÀH¾÷ÅÜ´«¨Ò¡G
  1. import random
  2. for i in xrange(10):
  3.     hs = ['Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36',
  4.            'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16',
  5.            'Mozilla/5.0 (Linux; U; Android 4.1.2; zh-tw; GT-I9300 Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30',
  6.            'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10'     
  7.            'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)']
  8.     headers = {"User-Agent":random.choice(hs)}
  9.     print headers
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ­n¥Î¤ß¡A¤£­n¾Þ¤ß¡B·Ð¤ß¡C
ªð¦^¦Cªí ¤W¤@¥DÃD