python向網頁提交資料

2021-07-03 12:48:15 字數 1744 閱讀 2485

源**:以**為例(該網頁並非使用非同步載入方法)

#-*-coding:utf8-*-

importrequests

importre

#url = ''

#html = requests.get(url).text

#print html.encode("gb18030")

#用於使用非同步載入方法的**,直接改變page的引數值即可
url ='&template=false'

data =

html_post = requests.post(url,data=data)

title = re.findall('"card-title">(.*?)',html_post.text,re.s)

foreachintitle:

printeach.encode("gb18030")

執行結果:是篩選出部分網頁資訊
d:\python27\python.exe d:/pycharm/class2/company.py

carlson wireless technologies inc.

outski inc.

ruyo inc

equities.com, inc.

playground sessions

p2p cash

effluent free desalination corporation a/k/a efd corp.

axcent tuning systems

phoenix financial holdings, inc.

sport-11

bakersfield investment club

ldr [lee-der] brands

fab financial inc.

gun academy

ascenergy

ipelli design

contour foods, llc

onemarket

businesspace, marketing, publicity and communication corp.

mine shaft brewing

trubrain

hamilton investment properties community housing

bstriker

clypcall

digitzs

su labs accelerator seed fund

slidebatch

tracemyfile

banter

freestar energy group

wine******, inc.

photosurvey

process finished with exit code 0
注意問題:編碼不匹配問題將輸出的編碼 格式改為gb18030,**為:printeach.encode("gb18030")

C 請求http向網頁傳送資料,網頁接收

首先,我們需要的是什麼東西?用post方式請求http,給網頁傳輸資料,網頁接收到資料之後,把資料儲存到資料庫中。1.首先請求http,建立連線,把轉碼過的資料傳輸過去 2.網頁接收資料,在轉碼之後儲存到資料庫 3.網頁返回乙個東西給傳輸方,表示我們已經接收到資料了 同樣,我們請求http也是用的控...

如何用vb向網頁傳送資料

有一網頁1.htm 請問如何做?用webbrowser 沒人用過嗎?winsock 一 用webbrowser 二 用inet 注意資料接收方式是post還是get 具體的方式是在1.htm的中 post方式 1 設定資料頭 2 設定要發的資料 3 傳送資料 inet.execute strsend...

Python3 向Bmob後台提交一條資料的範例

踩了不少坑之後終於得到了這個標準的範例python2只需要稍微改一下引用就可以了 context是你的表裡的列 test data json.dumps test data 此處將資料轉換成json格式才能提交,不然會返回107錯誤 requrl 1 classes myuser 替換為自己的表名 ...