python解析URL

2021年6月21日 06:32 by wst

python小技巧

在实际业务中,我们经常碰到需要解析URL的情况,这里把能列的东西全部列出,做个记录。

 

url示例:

url="https://report.baidu.com/malacca/report.do?uid=866369032262653&prov=1.0>m=1624242291507&appId=1133&channel_id=kuaiyi&version=6.5.0&sip=175.153.138.214&nodeId=1&adSpaceId=4617&adSpaceType=4&deviceModel=BND-AL10&imei=866369032262653&configId=1&operators=70123&network=4&adPlatform=1&eid=null&devisionId=488548120&from=3&etype=7&reqId=f6778a938a7543a19183041c05995ea4&mateId=d41a4b88b7a03892865c0d9102288e6d&adId=1159254694804136798&tasid=a11a5n&taid=0f3fe053de7e669a074992b1fcaeee72&adSrc=42&tk=450be53669615d29f3046a710d08e0ef"

解析步骤:

1. 解析出所有部分;

2. 解析查询参数;

 

具体代码如下:

from urllib.parse import urlparse, parse_qsl
import html

url = "https://report.baidu.com/malacca/report.do?uid=866369032262653&prov=1.0>m=1624242291507&appId=1133&channel_id=kuaiyi&version=6.5.0&sip=175.153.138.214&nodeId=1&adSpaceId=4617&adSpaceType=4&deviceModel=BND-AL10&imei=866369032262653&configId=1&operators=70123&network=4&adPlatform=1&eid=null&devisionId=488548120&from=3&etype=7&reqId=f6778a938a7543a19183041c05995ea4&mateId=d41a4b88b7a03892865c0d9102288e6d&adId=1159254694804136798&tasid=a11a5n&taid=0f3fe053de7e669a074992b1fcaeee72&adSrc=42&tk=450be53669615d29f3046a710d08e0ef"

parse_obj = urlparse(url)
print("parse_obj:", parse_obj)
print("协议:", parse_obj.scheme)
print("域名:", parse_obj.netloc)
print("请求路径:", parse_obj.path)
print("查询字符串(原始):", parse_obj.query)

# html中的特殊符号解码
query = html.unescape(parse_obj.query)
print("查询字符串(转换):", query)
parse_query = parse_qsl(query)
print("查询参数:", dict(parse_query))

 


Comments(130) Add Your Comment

Charlesnag
“I haven’t seen you in these parts,” the barkeep said, sidling over to where I sat. “Personage’s Bao.” He stated it exuberantly, as if low-down of his exploits were shared by way of settlers around multifarious a ‚lan in Aeternum. He waved to a expressionless keg hard by us, and I returned his gesticulate with a nod. He filled a glass and slid it to me across the stained red wood of the bench before continuing. “As a betting chains, I’d be delighted to wager a adequate piece of coin you’re in Ebonscale Reach for the purpose more than the wet one's whistle and sights,” he said, eyes glancing from the sword sheathed on my with it to the salaam slung across my back. https://www.google.com.lb/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&docid=kxhPLp0g5v6m6M&tbnid=F2KagBJ_pc47UM:&ved=0CAUQjRw&url=https://renewworld.ru/sistemnye-trebovaniya-new-world/
Kevingaw
https://maps.google.tg/url?q=https://betonlinecasinobonuscodes.com/pl/ http://www.google.mu/url?q=https://schlossgut.de/news/welche_online_casinos_sind_in_deutschland_legal__1.html https://images.google.com.py/url?q=https://www.feldbahn-ffm.de/wp-content/pages/wie_man_blackjack_in_einem_casino_spielt_und_gewinnt.html https://www.simacek.com/present/inc/wie_man_ein_casino_online_schl_gt__clevere_tipps_f_r_anf_nger_und_erfahrene_spieler.html https://www.karl-georg.de/tmp/welches_casino_zahlt_am_schnellsten_aus______die_ehrlichsten_vertrauensw_rdigen_casinos.html
Kevingaw
https://www.google.ps/url?sa=t&source=web&cd=6&ved=0CDsQFjAF&url=http://die-fototasse.de/wp-content/plugins/element/welches_online_casino_ist_zu_empfehlen___1.html http://images.google.com.ua/url?q=https://kommstdu-hierher.de/wp-includes/inc/welches_casino_spielt_knossi_.html https://www.karl-georg.de/tmp/welches_casino_zahlt_am_schnellsten_aus______die_ehrlichsten_vertrauensw_rdigen_casinos.html http://maps.google.no/url?q=http://cloudbetwelcomebonus.com/de/ http://www.google.je/url?q=http://miss-mole.de/wp-content/pages/online_kasinos_in_polen.html
Fpbyff
buy atorvastatin 10mg sale <a href="https://lipiws.top/">atorvastatin 10mg usa</a> lipitor 80mg uk
Arzehd
purchase cipro without prescription - <a href="https://metroagyl.top/oxytetracycline/">order ethambutol 600mg generic</a> buy augmentin 375mg without prescription
Awfued
buy generic cipro - <a href="https://cipropro.top/">buy cipro paypal</a> order augmentin 1000mg online cheap
Sbobxb
metronidazole ca - <a href="https://metroagyl.top/clindamycin/">order cleocin 150mg without prescription</a> zithromax 250mg uk
Zhfjvi
buy ciprofloxacin 500 mg generic - <a href="https://septrim.top/tinidazole/">order tindamax for sale</a> erythromycin drug
Ypdgmj
valtrex 1000mg uk - <a href="https://gnantiviralp.com/">buy cheap valtrex</a> zovirax pill
Ifyrsp
buy ivermectin 12mg - <a href="https://keflexin.top/ceftin/">axetil canada</a> order tetracycline 500mg for sale
Trrvpr
order flagyl without prescription - <a href="https://metroagyl.top/cefaclor/">cefaclor capsules</a> brand zithromax
Jlqncy
acillin ca <a href="https://ampiacil.top/doxycyclineantb/">buy monodox generic</a> buy cheap amoxil
Jvxbaj
furosemide where to buy - <a href="https://antipathogenc.com/minipressm/">prazosin 2mg uk</a> buy captopril without prescription
Okftqz
buy metformin 500mg generic - <a href="https://gnantiacidity.com/septra/">buy bactrim 480mg pills</a> order lincocin 500 mg online cheap
Fhzmyy
buy zidovudine without prescription - <a href="https://canadiangnp.com/zyloprim/"></a> order allopurinol 100mg
Ogwuni
where can i buy clozapine - <a href="https://genonlinep.com/">purchase clozapine generic</a> pepcid drug
Afbktt
quetiapine over the counter - <a href="https://gnkantdepres.com/effexor/">order venlafaxine 150mg</a> eskalith ca
Zftyyo
order anafranil generic - <a href="https://antdeponline.com/tofranil/">pill imipramine</a> doxepin 75mg ca
Mbjulu
hydroxyzine for sale - <a href="https://antdepls.com/">atarax 10mg oral</a> amitriptyline generic
Dhhhca
augmentin oral - <a href="https://atbioinfo.com/ampicillin/">buy acillin medication</a> cipro 500mg for sale
Jxdsgq
buy amoxil no prescription - <a href="https://atbioxotc.com/">where can i buy amoxicillin</a> order generic cipro 1000mg
Hoehco
buy cleocin - <a href="https://cadbiot.com/cefpodoxime/">buy vantin generic</a> brand chloromycetin
Yidewe
buy azithromycin 500mg sale - <a href="https://gncatbp.com/dofloxacin/">buy floxin for sale</a> order ciplox 500 mg generic
Szmhnd
stromectol online canada - <a href="https://antibpl.com/aqdapsone/">purchase aczone online</a> order cefaclor 250mg pills
Sfapru
albuterol 2mg inhaler - <a href="https://antxallergic.com/oiphenergan/">where to buy promethazine without a prescription</a> theo-24 Cr sale
Iucgsn
oral clarinex - <a href="https://rxtallerg.com/ventolinpill/">best antihistamine for runny nose</a> albuterol 2mg for sale
Rjrvuw
cost of medrol - <a href="https://ntallegpl.com/">methylprednisolone 16mg pills</a> astelin canada
Rldgui
cost glyburide 2.5mg - <a href="https://prodeprpl.com/glipizide10/">order glucotrol pills</a> buy generic forxiga online
Ikchkr
buy repaglinide 2mg sale - <a href="https://depressinfo.com/">buy cheap generic repaglinide</a> pill jardiance 10mg
Loqvre
order glycomet for sale - <a href="https://arxdepress.com/losartan25/">where to buy hyzaar without a prescription</a> order generic precose 25mg
Ftoksm
cheap lamisil - <a href="https://treatfungusx.com/xgrifulvinvs/">griseofulvin online order</a> purchase grifulvin v for sale
Wsyzmc
generic semaglutide - <a href="https://infodeppl.com/ddavpspray/">buy desmopressin without prescription</a> desmopressin usa
Wrzfud
buy cheap nizoral - <a href="https://antifungusrp.com/itraconazole100/">itraconazole 100mg over the counter</a> sporanox 100mg over the counter
Mdvioj
buy famvir generic - <a href="https://amvinherpes.com/">order famvir generic</a> valcivir buy online
Inkajq
purchase lanoxin pills - <a href="https://blpressureok.com/furosemidediuret/">lasix 40mg ca</a> furosemide medication
Czhvgs
buy microzide 25 mg generic - <a href="https://norvapril.com/amlodipine/">purchase amlodipine online cheap</a> zebeta cheap
Wcwwyk
metoprolol 50mg brand - <a href="https://bloodpresspl.com/nifedipine/">purchase nifedipine sale</a> adalat uk
Zcfszl
buy generic nitroglycerin for sale - <a href="https://nitroproxl.com/indapamide/">order indapamide 2.5mg generic</a> cheap diovan 80mg
Didgjm
simvastatin hurried - <a href="https://canescholest.com/fenofibrate/">fenofibrate fast</a> atorvastatin also
Ityxwu
rosuvastatin crowd - <a href="https://antcholesterol.com/caduet5mg/">caduet pills amiable</a> caduet pills total
Tdmowo
viagra professional online float - <a href="https://edsildps.com/eriacta/">eriacta waistcoat</a> levitra oral jelly warn
Gzgeqx
dapoxetine hospital - <a href="https://promedprili.com/suhagra/">suhagra worm</a> cialis with dapoxetine flap
Ueqalk
cenforce presence - <a href="https://xcenforcem.com/cialistadalafil/">cheap tadalafil</a> brand viagra ink
Eccoox
brand cialis position - <a href="https://probrandtad.com/brandlevitra/">brand levitra pursuit</a> penisole warm
Qtygnm
cialis soft tabs over - <a href="https://supervalip.com/">cialis soft tabs online parchment</a> viagra oral jelly attend
Oeudfb
brand cialis minister - <a href="https://probrandtad.com/penisole/">penisole much</a> penisole slam
Uixyru
cialis soft tabs pills fellow - <a href="https://supervalip.com/cavertapills/">caverta sensation</a> viagra oral jelly drift
Ysgfmp
cenforce quite - <a href="https://xcenforcem.com/kamagrasildenafil/">kamagra pills language</a> brand viagra spoon
Jxlusr
priligy name - <a href="https://promedprili.com/viagraplus/">viagra plus egg</a> cialis with dapoxetine thing
Tfsiox
acne treatment tempt - <a href="https://placnemedx.com/">acne medication fantastic</a> acne treatment would
Osejpd
asthma treatment above - <a href="https://bsasthmaps.com/">asthma medication abrupt</a> inhalers for asthma ever
Pxdgfc
uti treatment expression - <a href="https://amenahealthp.com/">uti medication above</a> uti medication monstrous
Yanmcz
prostatitis pills assemble - <a href="https://xprosttreat.com/">prostatitis treatment image</a> pills for treat prostatitis first
Bjpkec
valtrex pills base - <a href="https://gnantiviralp.com/">valacyclovir pills comment</a> valtrex idiot
Ftifyq
claritin pills grief - <a href="https://clatadine.top/">loratadine north</a> loratadine medication valley
Kcxcku
claritin pills party - <a href="https://clatadine.top/">claritin pills brow</a> loratadine medication goodness
Ngkqmq
priligy hurry - <a href="https://prilixgn.top/">dapoxetine auditor</a> priligy stuff
Jioieg
promethazine shoe - <a href="https://prohnrg.com/">promethazine mean</a> promethazine list
Rfwjrd
ascorbic acid mental - <a href="https://ascxacid.com/">ascorbic acid victim</a> ascorbic acid tremble
Eddmtu
biaxin part - <a href="https://gastropls.com/mesalaminepl/">asacol pills lofty</a> cytotec pills theory
Xmlali
fludrocortisone pills knee - <a href="https://gastroplusp.com/omepprilosec/">omeprazole fir</a> prevacid pills lend
Jjjzrg
bisacodyl online - <a href="https://gastroinfop.com/liv52/">buy liv52 10mg online cheap</a> order liv52 generic
Jfmtxl
aciphex tablet - <a href="https://gastrointesl.com/reglanmetoclop/">buy metoclopramide 10mg online cheap</a> motilium price
Oupnbr
buy bactrim 960mg sale - <a href="https://ketiracet.com/">purchase keppra online cheap</a> tobramycin 5mg price
Mdpqpg
buy generic hydroquinone online - <a href="https://cerazestrel.com/">cerazette 0.075 mg cheap</a> duphaston 10mg over the counter
Kcetal
forxiga 10 mg over the counter - <a href="https://precarbos.com/">acarbose 50mg for sale</a> buy precose 50mg generic
Xyfkof
buy fulvicin 250mg generic - <a href="https://dipyrilx.com/">dipyridamole 25mg oral</a> gemfibrozil 300 mg us
Wmaahw
order enalapril 5mg sale - <a href="https://doxapisin.com/">doxazosin over the counter</a> purchase zovirax
Ofckkg
dramamine 50mg without prescription - <a href="https://actodronate.com/">risedronate 35mg pills</a> risedronate 35 mg cheap
Tkgucx
order monograph 600 mg sale - <a href="https://etodograph.com/">monograph buy online</a> pletal 100 mg cost
Zlwurk
cheap piroxicam 20mg - <a href="https://rivastilons.com/">rivastigmine 3mg ca</a> cost exelon
Nokesp
order piracetam sale - <a href="https://nootquin.com/praziquantel/">biltricide without prescription</a> sinemet 20mg cost
Ggweej
hydroxyurea tablet - <a href="https://hydroydrinfo.com/indinavir/">buy crixivan tablets</a> robaxin brand
Zvzxxf
depakote 500mg pill - <a href="https://adepamox.com/amiodarone/">buy cordarone no prescription</a> topiramate 200mg brand
Uyyijh
buy generic disopyramide phosphate - <a href="https://anorpica.com/pregabal/">order pregabalin 150mg for sale</a> brand chlorpromazine 100mg
Vfezke
cytoxan generic - <a href="https://cycloxalp.com/trimetazidine/">buy vastarel for sale</a> vastarel tablets
Uwcufx
spironolactone usa - <a href="https://aldantinep.com/naltrexone/">naltrexone 50mg cheap</a> purchase naltrexone sale
Ctglpr
flexeril us - <a href="https://abflequine.com/donepezil/">where to buy aricept without a prescription</a> purchase enalapril without prescription
Dcqoon
purchase ondansetron sale - <a href="https://azofarininfo.com/">order zofran generic</a> purchase ropinirole without prescription
Ncelww
ascorbic acid price - <a href="https://mdacidinfo.com/prochlorperazine/">purchase compro without prescription</a> cheap prochlorperazine generic
Antkky
purchase durex gel online - <a href="https://xalaplinfo.com/latanoprosteyedrops/">order zovirax</a> purchase latanoprost without prescription
Auqsqk
rogaine price - <a href="https://hairlossmedinfo.com/finasteridepros/">proscar pills</a> buy propecia without a prescription
Jnxqol
arava 20mg ca - <a href="https://infohealthybones.com/">leflunomide over the counter</a> cartidin for sale online
Ifpjcy
buy atenolol 50mg - <a href="https://heartmedinfox.com/">buy tenormin pill</a> coreg 25mg brand
Xkjyzc
verapamil 120mg ca - <a href="https://infoheartdisea.com/">buy calan 120mg pill</a> tenoretic cost
Dtbdyc
buy atorvastatin generic - <a href="https://infoxheartmed.com/enalapril/">enalapril 10mg over the counter</a> order generic nebivolol
Vjvmjg
buy gasex tablets - <a href="https://herbalinfomez.com/">buy gasex tablets</a> cheap diabecon online
Cikdym
lasuna for sale online - <a href="https://infoherbalmz.com/himcolin/">purchase himcolin generic</a> order himcolin online cheap
Couulh
cheap noroxin without prescription - <a href="https://gmenshth.com/confido/">confido oral</a> cheap confido generic
Yfpelt
speman generic - <a href="https://spmensht.com/">speman buy online</a> buy fincar pills for sale
Epyaau
brand finax - <a href="https://finmenura.com/alfuzosin/">order uroxatral 10 mg pills</a> alfuzosin 10mg cheap
Doggwd
terazosin 5mg pills - <a href="https://hymenmax.com/dutasteride/">avodart 0.5mg cost</a> buy priligy 60mg without prescription
Lokeap
order oxcarbazepine online - <a href="https://trileoxine.com/levothyroxine/">buy levothyroxine</a> how to get synthroid without a prescription
Wbvtxw
duphalac usa - <a href="https://duphalinfo.com/betahistine/">betahistine 16mg pills</a> order betahistine 16 mg generic
Ftbgqz
cheap cyclosporine - <a href="https://asimusxate.com/methotrexate/">buy methotrexate 10mg generic</a> order generic colchicine
Rwrykp
calcort usa - <a href="https://lazacort.com/">cheap deflazacort for sale</a> oral brimonidine
Hldjbv
neurontin 600mg price - <a href="https://aneutrin.com/">neurontin 800mg without prescription</a> buy azulfidine 500 mg for sale
Ijljmt
where can i buy besivance - <a href="https://besifxcist.com/sildamax/">buy sildamax medication</a> sildamax price
Qofaie
buy celebrex 100mg for sale - <a href="https://celespas.com/">celecoxib 100mg price</a> indomethacin 50mg pills
Qyvqyk
buy benemid 500mg for sale - <a href="https://bendoltol.com/carbamazepine/">buy tegretol 400mg online</a> buy tegretol 400mg without prescription
Ldmopd
purchase diclofenac - <a href="https://dicloltarin.com/">buy generic cambia online</a> aspirin drug
Xiphhk
order mebeverine 135 mg online - <a href="https://coloxia.com/etoricoxib/">oral arcoxia</a> cilostazol 100mg for sale
Xhbhhu
buy mestinon 60 mg generic - <a href="https://mestonsx.com/">mestinon 60mg tablet</a> oral azathioprine 25mg
Rtigdy
rumalaya tablets - <a href="https://rumaxtol.com/">order rumalaya pill</a> order elavil 50mg generic
Qsqtvr
baclofen drug - <a href="https://baclion.com/nspiroxicam/">feldene 20mg pills</a> buy feldene 20mg generic
Izjctq
diclofenac online buy - <a href="https://vovetosa.com/tisosorbide/">how to buy imdur</a> nimotop where to buy
Gclmyh
order cyproheptadine generic - <a href="https://periheptadn.com/">purchase cyproheptadine online</a> buy generic tizanidine 2mg
Hcsitz
order meloxicam generic - <a href="https://meloxiptan.com/asrizatriptan/">buy maxalt for sale</a> toradol 10mg oral
Whhqiz
cefdinir 300 mg ca - <a href="https://omnixcin.com/aminocycline/"></a> clindamycin uk
Pyzuar
cheap artane tablets - <a href="https://voltapll.com.com/">cheap trihexyphenidyl online</a> order emulgel sale
Crbige
deltasone order - <a href="https://apreplson.com/">deltasone 5mg uk</a> purchase zovirax online cheap
Edupqy
accutane 10mg without prescription - <a href="https://aisotane.com/">where to buy isotretinoin without a prescription</a> buy deltasone pill
Kxttch
buy betamethasone 20 gm generic - <a href="https://betnoson.com/awdifferin/">buy adapalene cream</a> buy monobenzone sale
Oitqgj
buy flagyl generic - <a href="https://cenforcevs.com/">order cenforce 100mg pill</a> cenforce tablet
Triwgh
clavulanate cost - <a href="https://alevonted.com/">order generic levothroid</a> cheap generic synthroid
Wfdpjn
buy cozaar for sale - <a href="https://acephacrsa.com/">cost keflex 500mg</a> order keflex 250mg pill
Kvvtag
cleocin 150mg canada - <a href="https://indometnp.com/">cheap indomethacin 50mg</a> order indomethacin 75mg sale
Ostulr
order modafinil 100mg generic - <a href="https://sleepagil.com/">oral provigil</a> buy melatonin 3mg online
Gxgise
crotamiton cheap - <a href="https://aeuracream.com/">buy cheap eurax</a> order aczone sale
Zfnejx
buy zyban 150mg without prescription - <a href="https://bupropsl.com/ayurslim/">ayurslim pills</a> cheap shuddha guggulu sale
Wqhwjn
buy capecitabine 500 mg online - <a href="https://xelocap.com/naproxen/">buy naproxen online cheap</a> buy danazol medication
Afwtln
order prometrium 100mg online cheap - <a href="https://apromid.com/">progesterone 100mg tablet</a> clomiphene pills
Vuiovw
order fosamax 70mg sale - <a href="https://pilaxmax.com/tamoxifen/">order nolvadex generic</a> buy medroxyprogesterone 5mg online cheap
Mgwlnl
order norethindrone 5mg - <a href="https://norethgep.com/">aygestin 5 mg usa</a> cheap yasmin without prescription
Oyvxpq
estradiol pills - <a href="https://festrolp.com/">purchase estradiol online</a> order arimidex pill
Ihexnt
dostinex online order - <a href="https://adostilin.com/cabgolin/">cabgolin canada</a> buy alesse no prescription
Btepev
プレドニン 個人輸入 おすすめ - <a href="https://jpaonlinep.com/">プレドニン通販おすすめ</a> アジスロマイシン は通販での購
Xwrmzy
シルデナフィル は通販での購 - <a href="https://jpedpharm.com/">バイアグラ 値段</a> シアリス通販おすすめ
Ibhbur
正規品プレドニン錠の正しい処方 - <a href="https://jpanfarap.com/">プレドニンの購入</a> イソトレチノイン通販で買えますか
Hpxiwh
eriacta horrible - <a href="https://eriagra.com/asildigrah/">sildigra fasten</a> forzest mister