• 使用正则表达式,取得点击次数,函数抽离


    1.import re;
    def isEmailAccount(str):
        if(re.match("w*@w*(.w{2,3}){1,3}$",str)):
            return True
        else:
            return False
    print(isEmailAccount('123sdf_sd@qq.com.cm'))
    print(isEmailAccount('123sdf_sd@qq'))
    
    
    2.import re;
    import requests
    newurl='http://news.gzcc.cn/html/2018/xiaoyuanxinwen_0404/9183.html'
    res = requests.get(newurl)
    res.encoding='utf-8'
    tel=re.findall("(d{3,4}) *- *(d{7,8})",res.text)
    
    
    3.import re;
    str="""In this year's government work report, Premier Li Keqiang frequently referred to internet-related concepts, like Internet Plus, artificial intelligence, and Digital China, and noted that the Chinese government will give priority to "providing more and better online content"."""
    a=re.split('[s,.?" ]+',str)
    print(a)
    
    
    
    6.import re
    import requests
    url="http://news.gzcc.cn/html/2018/xiaoyuanxinwen_0404/9183.html"
    newId=re.search("/(d*).html$",url).group(1)
    print(newId)
    clickUrl ="http://oa.gzcc.cn/api.php?op=count&id={}&modelid=80".format(newId)
    print(clickUrl)
    resc = requests.get(clickUrl)
    num = re.search(".html('(d*)')",resc.text).group(1)
    print(num)
  • 相关阅读:
    Vmware安装Ubuntu ==> 连网成功
    在 ns3.25中添加 plc(电力线载波) 模块
    Ubuntu12.04下安ns3.29及Ubuntu换源方法
    微信支付小程序版
    微信小程序打开外部链接
    linux下安装Mongodb
    延迟执行+异步 之代码分析1
    Vue入门
    实验一
    实验二
  • 原文地址:https://www.cnblogs.com/cyn-kk/p/8762518.html
Copyright © 2020-2023  润新知