python向网页提交数据

源代码:以https://www.crowdfunder.com/deals网站为例(该网页并非使用异步加载方法)

#-*-coding:utf8-*-
import requests

import re
#url = 'https://www.crowdfunder.com/deals'
#html = requests.get(url).text
#print html.encode("gb18030")
 
 
#用于使用异步加载方法的网站,直接改变page的参数值即可
url = 'https://www.crowdfunder.com/deals&template=false'




data = {

    'entities_only':'true',

    'page':'1'
}

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

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

for each in title:

    print each.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

WineSimple, Inc.

PhotoSurvey
Process finished with exit code 0
注意问题:编码不匹配问题将输出的编码 格式改为gb18030,代码为:print each.encode("gb18030")
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值