[問題] 關於回傳值
我從另一個網頁傳url,name,key,gRule
可是,我的gRule並不是收到的那個涵數要用的
而是httpparser要用的
程式碼如下:
---
class parseLinks(HTMLParser.HTMLParser):
def handle_starttag(self, tag, attrs):
if tag == 'a':
for name,value in attrs:
if name == 'href':
result = re.search("catitemid=",value)
if result is None:
break
else:
print value
print " "
def webparser(request):
if (request.has_key("url") and request.has_key("content") and request.has_key("key") and request.has_key("gRule")):
if (request.POST["url"]=="" or request.POST["content"]=="" or request.POST["key"]=="" or request.POST["gRule"]==""):
return render_to_response('parser.html')
else:
a=request.POST["url"]
lParser = parseLinks()
lParser.feed(urllib.urlopen(a).read())
lParser.close()
return render_to_response('parser.html')
---
result = re.search("cartitemid=",value)
裡面的cartitemid其實是webparser函數裡面收到的值 request.POST["gRule"]
可是,我不知道該怎麼把函數收到的這個值,送到httpparser裡面
讓他變成使用者輸入的方向(我現在是寫死的)
請問有人會嗎>"<
請教一下,謝謝!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.172.216.17
推
09/12 22:46, , 1F
09/12 22:46, 1F
→
09/12 22:47, , 2F
09/12 22:47, 2F
謝謝你:D
我用你的方法有成功^^*
※ 編輯: mirror012020 來自: 218.172.216.17 (09/13 01:01)
Python 近期熱門文章
PTT數位生活區 即時熱門文章