zoukankan      html  css  js  c++  java
  • 使用正则表达式,取得点击次数,函数抽离

    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)
  • 相关阅读:
    RocketMQ Message hasn't been sent. Caused by No route info of this topic, test-topic
    Barrier
    WPF之资源
    WPF之命令
    WPF之事件
    WPF之属性
    多路Binding
    Binding的数据转换
    Binding的数据校验
    为Binding指定源的方法
  • 原文地址:https://www.cnblogs.com/bjdx1314/p/8762801.html
Copyright © 2011-2022 走看看