Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

BeautifulSoup Python×¥ÍøÒ³Ð¡Àý×Ó

# -*- coding: utf-8 -*-
import urllib2
from BeautifulSoup import BeautifulSoup, Tag
import re
page = urllib2.urlopen("http://bj.ganji.com/piao/zz_%E5%8C%97%E4%BA%AC-%E5%8D%97%E6%98%8C/20100210/")
soup = BeautifulSoup(page)
#ss = soup.findAll('a', href=re.compile(r"^/piao/100."))
ss = soup.findAll(attrs={"class":"list_piao"})
fp = open("c:\\Python25\\web.html","w")
doc = '''<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>keyunq tickets</title>
<meta http-equiv="refresh" content="5"/>
<link href="http://s1.ganjistatic1.com/css/base.__1265015655__.css" mce_href="http://s1.ganjistatic1.com/css/base.__1265015655__.css" rel="stylesheet" type="text/css" />
<link href="http://s1.ganjistatic1.com/css/train.__1264669543__.css" mce_href="http://s1.ganjistatic1.com/css/train.__1264669543__.css" rel="stylesheet" type="text/css" />
<mce:style><!--
.list_piao dt { float:left; width:40%; line-height:24px; font-size:14px; text-indent:5px;padding:5px 0;}
--></mce:style><style mce_bogus="1">.list_piao dt { float:left; width:40%; line-height:24px; font-size:14px; text-indent:5px;padding:5px 0;}</style>
</head>
<body>'''
fp.write('%s\n' % doc)
for i in ss:
i.dt['class'] = 'list_piao_time'
tmp = i.a['href']
i.a['href'] = 'http://bj.ganji.com'+tmp
phonepage = urllib2.urlopen(i.a['href'])
phonesoup = BeautifulSoup(phonepage)
phone = phonesoup.findAll(attrs={"class":"phoneNum"})
tmp = phone[0].img['src']
phone[0].img['src'] = 'http://bj.ganji.com'+tmp
tag1 = Tag(soup, "dd")
tag1['class'] = 'list_piao_mj'
i.insert(8,tag1)


Ïà¹ØÎĵµ£º

Python¼òÒ׹ɯ±²éѯ(ץȡgoogle²Æ¾­µÄÄÚÈÝ)


¿´×ÅÍøÉÏ×¥È¡ÍøÒ³Êý¾ÝµÄÎÄÕÂÖ±µÉÑÛ
ºóÀ´Ïëµ½ÓÃ×Ö·û´®·Ö¸îÀ´ÌáÈ¡ÏàÓ¦²¿·ÖµÄÄÚÈÝ
³ÌÐò¼òµ¥£¬µ«ÊýÐÐÊýºÍϱê·ÑÁ˺ܳ¤Ê±¼ä
ÎÒÖªµÀÕâ¿Ï¶¨²»ÊÇ×îºÃµÄ°ì·¨- -!!
µ«ÎÒʵÏÖÁË£¬¹þ¹þ
# -*- coding: cp936 -*-
from urllib import *
import re
def stockSearch():
    baseurl="http://www.google.cn/financ ......

¡¾python¡¿ÈçºÎ¶ÁÈ¡ÃüÁîÐеÄÊä³ö

Èç¹ûpythonµ÷ÓÃÍⲿ³ÌÐò£¬ÐèÒªÖ±½ÓץȥÃüÁîÐеÄÊä³ö£¬ÓÐʲôºÃµÄ°ì·¨ÄØ£¿
ÕâÀïÎÒÃÇÐèÒªÓõ½ os.popen Õâ¸ö¹ÜµÀ£¬È»ºóÓà read¡¢readline»òÕßreadlinesÀ´¶ÁÈ¡ÃüÁîÐÐÊä³ö
#ÐèÒªÖ´ÐеÄÃüÁî
strCommand = 'xxxxxxxxxxxxxxxxx'
#ÓÃpopenÀ´Ö´ÐÐÃüÁîÐÐ
oStdout = os.popen(strCommand)
#¼ÙÉèÊä³öµÄÄÚÈÝÖ»ÓÐÒ»ÐÐ
strStdout = ......

ÔÚpythonÖÐʹÓÃdllµ¼³öº¯Êý

×î½üÔÚѧϰpy£¬Êµ¼ùÊÇ£ºÐ£ÑéÖ¸¶¨ÎļþÊÇ·ñ´òÉÏÊý×ÖÇ©Ãû~pythonµÄ±ê×¼¿âÖÐûÓÐÌṩÕâÀຯÊý£¬Í¬Ê±ÔÚÍøÉÏËÑÁËÒ»ÏÂҲûÓÐÕÒµ½µÚÈý·½µÄ°üÓÐÌṩ£¬×îºóÕÒµ½ÁË¿ÉÒÔʹÓÃCrypt32.dllµÄµ¼³öº¯ÊýCryptQueryObject()¡£
Ê×ÏÈÎÒÏ£Íûpywin32µÄ°üÖÐ×îºÃÒÑ·â×°ÕâÑùµÄapi£¬½á¹û·¢ÏÖûÓÐ-_-!¡£ÓÚÊDz»µÃ²»×Ô¼º¶¯ÊÖ~pyÖе÷ÓÃdllµÄµ¼³öº¯Êý·½·¨±È ......

½â¶ÁÓÃpythonд×Ô¼ºµÄlinux²¥·ÅÆ÷£¨1£©

¡¡¡¡½ÓÏÂÀ´ÈýÐÐÉèÖÃÈýÖÖ¹¦ÄÜ£¬treeview.set_search_column(0)£¬µ±ÔÚ½çÃæÖа´“Control+F”ʱ¿ÉÒÔËÑË÷µÚ0ÁÐÖеÄÄÚÈÝ£¬tvcolumn.set_sort_column_id(0)£¬µ±µã»÷´ËÁбêÌâµÄʱºòËùÓеÄÐа´´óС˳ÐòÖØÐÂÅÅÁС£²ÎÊý0ÊÇ
ÁÐÔÚModelÀïµÄÐòºÅ¡£½ÓÏÂÀ´treeview.set_reorderable·½·¨Ê¹µÃ¿ÉÒÔÓÃÊó±êÍ϶¯ÐнøÐÐÖØÐÂÅÅÁУ¬±ÈÈç£ ......

PythonµÄASCII, GB2312, Unicode , UTF 8

PythonµÄASCII, GB2312, Unicode , UTF-8
ASCII ÊÇÒ»ÖÖ×Ö·û¼¯,°üÀ¨´óСдµÄÓ¢ÎÄ×Öĸ¡¢Êý×Ö¡¢¿ØÖÆ×Ö·ûµÈ£¬ËüÓÃÒ»¸ö×Ö½Ú±íʾ£¬·¶Î§ÊÇ 0-127 Unicode·ÖΪUTF-8ºÍUTF-16¡£
UTF-8±ä³¤¶ÈµÄ£¬×î¶à 6 ¸ö×Ö½Ú£¬Ð¡ÓÚ 127 µÄ×Ö·ûÓÃÒ»¸ö×Ö½Ú±íʾ£¬Óë ASCII ×Ö·û¼¯µÄ½á¹ûÒ»Ñù£¬ASCII ±àÂëϵÄÓ¢ÓïÎı¾²»ÐèÒªÐ޸ľͿÉÒÔµ±×÷ UTF-8 ±àÂë ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ