craw_ptt.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:Crawler_and_Share 作者: f496328mm 项目源码 文件源码
def catch_ptt_max_index(ptt_class_name,sql_name):
    conn = ( pymysql.connect(host = '114.34.138.146',
                             port = 3306,
                             user = user,
                             password = password,
                             database = database,  
                             charset="utf8") )
    cursor = conn.cursor()
    cursor.execute('SELECT * FROM `'+ sql_name +'` ORDER BY id DESC LIMIT 1;')
    data = cursor.fetchone()       


    index = data[10]
    index = index.replace('http://www.ptt.cc/bbs/'+ ptt_class_name +'/index','')
    index = index.replace('.html','')
    index = int(index)

    cursor.close()
    conn.close()    

    return index
#---------------------------------------------------------------------------------  
#---------------------------------------------------------------------------------  
# ? SQL ? data ???, ?data?????? SQL ? max data time
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号