杩欐槸涓涓緢闀跨殑鏁呬簨锛屽珜闀跨殑鐩存帴鐪嬫渶鍚庣殑缁撹

浜嬫儏缁忚繃

涓婂懆鎺ヤ簡涓渶姹傦紝鍐欎簡涓皬宸ュ叿缁欏鎴凤紝浠栬姹傛墦鍖呮垚exe鏂囦欢锛岃繖褰撶劧涓嶆槸浠涔堥毦浜嬨傚洜涓洪櫎浜嗗啓Python鐨勶紝缁濆ぇ澶氭暟浜虹數鑴戦噷閮芥病鏈塒ython缂栬瘧鍣紝鎵浠ユ墦鍖呮垚exe锛岃鐢ㄦ埛(windows)鍙屽嚮灏卞彲浠ユ墦寮锛屼篃绠楁槸蹇呭鎶鑳戒簡銆

鐩存帴鐢≒yinstaller锛屾墦寮cmder:

pyinstaller -Fw E:\test\url_crawler.py

(-F 鏄墦鍖呮垚涓涓枃浠讹紝-w鏄笉鍑虹幇璋冭瘯绐楀彛锛屽洜涓烘垜鐨勫皬宸ュ叿閲屾湁GUI锛屾墍浠ヤ笉鐢ㄩ粯璁ょ殑璋冭瘯绐楀彛)

绛変簡濂戒箙锛岀粓浜庡畬鎴愭墦鍖咃紝涓鐪嬫枃浠讹紝鍤紝200M锛佹笉寰楁墦鍖呬簡杩欎箞涔...

涓婄綉鏌ヤ簡涓嬭祫鏂欙紝鏈変汉璇达紝Anaconda閲屽唴缃簡寰堝搴擄紝鎵撳寘鐨勬椂鍊欐墦鍖呬簡寰堝涓嶅繀瑕佺殑妯″潡杩涘幓锛岃鐢ㄧ函鍑鐨凱ython鏉ユ墦鍖呫

鏈夌偣閬撶悊锛屾兂鐫瑁呰櫄鎷熸満鏃堕棿鏇撮暱锛屽噯澶囨嬁鍑洪棽缃殑绗旇鏈紝閲嶆柊瑁呬釜Python鏉ユ墦鍖呫

鍙垰宸ф垜鏈杩戝湪瀛lask鐨勬椂鍊欙紝鐢ㄥ埌pipenv锛岃櫧鐒惰繕涓嶆噦pipenv鐨勫己澶т箣澶勶紝浣嗙煡閬撳畠鏄釜绠$悊铏氭嫙鐜鍜屽寘鐨勫伐鍏凤紝浜庢槸鎯崇潃鑳戒笉鑳界敤pipenv鏉ュ垱寤轰竴涓柊鐨刾ython缂栬瘧鍣ㄤ互杩愯pyinstaller杩涜鎵撳寘銆

浜庢槸璧剁揣涓婄綉鏌ヤ簡涓涓嬶紝pipenv pyinstaller锛屾病鏈夋悳鍒版湁鐢ㄧ殑淇℃伅锛屽共鑴嗚嚜宸辫瘯涓璇曪紝鍙嶆pipenv鎿嶄綔涓嶉夯鐑︺

鎵撳紑cmder:

#寤虹珛铏氭嫙鐜

pipenv install

#杩涘叆铏氭嫙鐜

pipenv shell

#瀹夎妯″潡

pip install 灏忓伐鍏.py閲岄潰鐢ㄥ埌鐨勬ā鍧

#鎵撳寘鐨勬ā鍧椾篃瑕佸畨瑁

pip install pyinstaller

#寮濮嬫墦鍖

pyinstaller -Fw E:\test\url_crawler.py

鎵撳寘瀹屾垚锛屼竴鐪嬪ぇ灏忥紝11M锛佹垚鍔燂紒

鍚庢潵鍥犱负瀹㈡埛鏀逛簡闇姹傦紝鎴戝張鏀逛簡涓涓嬫簮浠g爜锛岀劧鍚庢崲浜嗕釜鐩綍鐢╬ipenv閲嶆柊鎵撳寘锛岀粨鏋滄墦鍖呭畬鍙堝彉鍥200M锛佸皾璇曚簡鏃犳暟娆★紝鎬庝箞涔熷洖涓嶅埌杩囧幓鐨20M锛佹垜閮芥鐤戜箣鍓嶇殑20M鏄垜鐨勫够瑙変簡銆

涓嶈繃鏃犺濡備綍瑕佸厛浜ゅ樊锛200M鐨勨滃皬鈥滃伐鍏凤紝鐢ㄦ埛浣撻獙鑲畾涓嶈锛屾墍浠ユ垜灏辩敤鎺掗櫎娉曪紝鐪嬬湅鏄摢涓ā鍧楀崰鐨勪綋绉ぇ锛屽啀鎯冲姙娉曚紭鍖栥傛渶鍏堟鐤戠殑鏄疓UI锛屾垜鍑犱箮姣笉鐘硅鲍鍦拌瀹氭槸瀹冿紝鎴戠敤鐨勬槸PySimpleGUI(寮虹儓鎺ㄨ崘锛屽熀浜巘kinter)锛屽厛鎶奝ySimpleGUI鐨勫唴瀹规敞閲婃帀锛屽啀杩涜鎵撳寘锛屼綘浠寽鎵撳寘瀹屾湁澶氬ぇ锛

198M锛

鐪嬫潵鏄垜閿欐粬浜嗭紝缁忚繃鍑犳鎺掗櫎锛屽彂鐜颁簡缃瓉绁搁灏辨槸锛歠ake_useragent

杩欎釜搴撴槸鐢ㄦ潵浼璇锋眰澶寸殑锛屼富瑕佹槸鎴戞噿寰楀鍒秛ser-agent锛屾墍浠ラ棶棰樹笉澶э紝鎶奻ake_useragent娉ㄩ噴鎺夛紝鑷繁鎵嬪姩绮樿创涓涓猽ser-agent灏辫浜

#from fake_useragent import UserAgent



#ua = UserAgent()

#headers = {'user-agent':ua.random}

headers = {'user-agent':'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.17 Safari/537.36'}

涓嶇敤fake_useragent锛屾墦鍖呮垚exe鏄 14M锛屽凡缁忎笉閿欎簡锛屽厛浜ゅ樊鍐嶈

涔嬪悗缁忚繃浜嗗娆℃帰绱紝澶氭鏀惧純鐨勮竟缂(鍙嶅鍒犻櫎鍒涘缓鐜)锛岀粓浜庢壘鍒颁簡瀹岀編鎵撳寘鐨勬柟娉

缁撹

鍏抽敭鐐瑰氨涓涓細瑕佸湪铏氭嫙鐜閲屽畨瑁卲yinstaller

濡傛灉浣犳病鏈夊湪铏氭嫙鐜涓畨瑁卲yinstaller锛屼綘鍚屾牱鍙互浣跨敤pyinstaller鍛戒护锛屼絾鏄皟鐢ㄧ殑鏄綘绯荤粺鍘熸湰鐨勯偅涓猵ython缂栬瘧鍣紝鍐呭惈寰堝鍏宠仈搴擄紝瀵艰嚧鍗充娇鍦ㄨ櫄鎷熺幆澧冧腑锛屼綘鎵撳寘鐨別xe鏂囦欢浠嶇劧闈炲父澶с

鍙﹀涓鐐硅娉ㄦ剰鐨勬槸锛氳鍦ㄨ櫄鎷熺幆澧冮噷瀹夎濂戒綘py鏂囦欢涓皟鐢ㄧ殑搴擄紝涓嶇劧鎵撳寘鍑烘潵涔熸病娉曟甯歌繍琛屻

鏈鍚庡啀澶嶄範涓涓嬫纭祦绋 (鍓嶆彁鏄畨瑁呭ソpipenv)锛

#寤虹珛铏氭嫙鐜

pipenv install

#杩涘叆铏氭嫙鐜(涓婁竴姝ュ彲鐪佺暐,鍥犱负娌℃湁铏氭嫙鐜鐨勮瘽浼氳嚜鍔ㄥ缓绔嬩竴涓)

pipenv shell

#瀹夎妯″潡

pip install requests pyquery pysimplegui fake_useragent

#鎵撳寘鐨勬ā鍧椾篃瑕佸畨瑁

pip install pyinstaller

#寮濮嬫墦鍖

pyinstaller -Fw E:\test\url_crawler.py
鈥斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺

                        
鍘熸枃杞浇鑷砪sdn鐨剋eixin_39799825锛岄摼鎺ワ細https://blog.csdn.net/weixin_39799825/article/details/113679014

浠ヤ笂灏辨槸Python 鐢╬yinstaller灏唒y杞琫xe鍚庢枃浠朵綋绉緢澶х殑缁忛獙銆愯浆杞姐戠殑璇︾粏鍐呭锛屾洿澶氫俊鎭鍏虫敞OD浜戝叾瀹冪浉鍏虫枃绔狅紒



鏈枃URL锛http://www.odweb.cn/news_show.html?id=276