社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

循环python脚本

Michael Brown • 5 年前 • 1395 次点击  

我需要一些关于python循环技术的帮助。 经过几天的寻找,我放弃了…

系统:windows(anaconda)

想法:“我创建了一个html解析器脚本,但是由于缺少python脚本的知识和经验,我似乎需要在每个页面上运行它。我无法修复它,这就是为什么我决定循环这个脚本,并使它运行100次100页“……但结果,我找不到正确的方法这样做……

我的剧本

import requests
import pandas as pd
import urllib.parse
import urllib.request
import re
import os
import sys



 url = "*******************/store/index.php"

 querystring ={"id":"***","act":"search","***":"***","country":"",
 "state":"*","city":"","zip":"","type":"","base":"","PAGENUM":"2"}

 headers = {
 'Host': "www.*****",
 'Connection': "keep-alive",
 'Upgrade-Insecure-Requests': "1",
 'User-Agent': "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 
 (KHTML, like Gecko) Chrome/64.0.3282.119 Safari/537.36",'Accept':"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
'Referer': "h************/store/index.php?id=********************&pagenum=2",
'Accept-Encoding': "gzip, deflate",
'Accept-Language': "en-US,en;q=0.9",
'Cookie': "php_session_id_real=**********; cookname=**********; cook******",
'cache-control': "no-cache",
'Postman-Token': "**************************"
}

 response = requests.request("GET", url, headers=headers,params=querystring)
 df_list = pd.read_html(response.text)
 df = df_list[-1]

 print(df)

我只需要更改pagenum querystring(例如: &页码=2,3,10,50 等)

是否可以运行此python脚本 X 时代, 每次改变 血小板计数 = 血小板计数 + 1??

希望得到你的建议!

干杯

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/43134
 
1395 次点击  
文章 [ 2 ]  |  最新文章 5 年前