CREATE DATABASE HELLO;

CREATE TABLE IF NOT EXISTS `botoo`(
`id` INT UNSIGNED AUTO_INCREMENT,
`title` VARCHAR(100),
`url` VARCHAR(100) ,
`downloadUrl` VARCHAR(100) NOT NULL unique,
`releaseTime` DATE,
`state` int(11) DEFAULT 1 ,
   `type`  VARCHAR(20) DEFAULT NULL,
`insertTime` DATE, PRIMARY KEY ( `id` ) )ENGINE=InnoDB DEFAULT CHARSET=utf8; insert into botoo (title,url,downloadUrl,releaseTime,insertTime) values('测试','http://www.baidu.com','www.baidu.com','2019-11-22 10:00:00','2019-11-22 10:00:01');
import pymysql.cursors
import time def localTime(): now = int(time.time())
timeStruct = time.localtime(now)
strTime = time.strftime("%Y-%m-%d %H:%M:%S", timeStruct)
return strTime def insertSqlLanguage(title,url,downloadUrl,releaseTime):
insertDate = f"('{title}','{url}','{downloadUrl}','{releaseTime}','{localTime()}')"
sqlLanguage = f"insert into sesese (title,url,downloadUrl,releaseTime,insertTime) values {insertDate}"
return sqlLanguage if __name__ == '__main__': connect= pymysql.Connect(
host='xxxxxxxx',
user='xxxxx',
password='xxxxxx',
port=3306,
db='xxxxxxxx',
charset='utf8')
cursor = connect.cursor()
insertSql = insertSqlLanguage('测试','http://www.baidu.com','www.baidu.com','2019-11-22 10:00:00') cursor.execute(insertSql)
connect.commit()

爬取的地址存入mysql记录的更多相关文章

  1. Python+Scrapy+Crawlspider 爬取数据且存入MySQL数据库

    1.Scrapy使用流程 1-1.使用Terminal终端创建工程,输入指令:scrapy startproject ProName 1-2.进入工程目录:cd ProName 1-3.创建爬虫文件( ...

  2. python爬取疫情数据存入MySQL数据库

    import requests from bs4 import BeautifulSoup import json import time from pymysql import * def mes( ...

  3. Java爬取51job保存到MySQL并进行分析

    大二下实训课结业作业,想着就爬个工作信息,原本是要用python的,后面想想就用java试试看, java就自学了一个月左右,想要锻炼一下自己面向对象的思想等等的, 然后网上转了一圈,拉钩什么的是动态 ...

  4. Python爬取热搜存入数据库并且还能定时发送邮件!!!

    一.前言 微博热搜榜每天都会更新一些新鲜事,但是自己处于各种原因,肯定不能时刻关注着微博,为了与时代接轨,接受最新资讯,就寻思着用Python写个定时爬取微博热搜的并且发送QQ邮件的程序,这样每天可以 ...

  5. 爬取伯乐在线文章(四)将爬取结果保存到MySQL

    Item Pipeline 当Item在Spider中被收集之后,它将会被传递到Item Pipeline,这些Item Pipeline组件按定义的顺序处理Item. 每个Item Pipeline ...

  6. python Requests库网络爬取IP地址归属地的自动查询

    #IP地址查询全代码import requestsurl = "http://m.ip138.com/ip.asp?ip="try: r = requests.get(url + ...

  7. python框架Scrapy中crawlSpider的使用——爬取内容写进MySQL

    一.先在MySQL中创建test数据库,和相应的site数据表 二.创建Scrapy工程 #scrapy startproject 工程名 scrapy startproject demo4 三.进入 ...

  8. 精通python网络爬虫之自动爬取网页的爬虫 代码记录

    items的编写 # -*- coding: utf-8 -*- # Define here the models for your scraped items # # See documentati ...

  9. python爬取ip地址

    ip查询,异步get请求 分析接口,请求接口响应json 发现可以data中获取 result.json()['data'][0]['location'] # _*_ coding : utf-8 _ ...

随机推荐

  1. Kubernetes架构及相关服务详解

    11.1.了解架构 K8s分为两部分: 1.Master节点 2.node节点 Master节点组件: 1.etcd分布式持久化存储 2.api服务器 3.scheduler 4.controller ...

  2. springboot之DevTools热部署的简单原理解析

    IDEA新建springboot选择DevTools springboot-devtools模块能够实现热部署,添加类.添加方法,修改配置文件,修改页面等,都能实现热部署. 原理就是重启项目,但比手动 ...

  3. java.util. Arrays.sort(scores);

    import java.util.*; public class ArraySortScore { //完成 main 方法 public static void main(String[] args ...

  4. HTTP1.0、HTTP1.1、HTTP2.0的关系和区别

    一.汇总对比 HTTP1.0 无状态.无连接HTTP1.1 持久连接请求管道化增加缓存处理(新的字段如cache-control)增加Host字段.支持断点传输等(把文件分成几部分)HTTP2.0 二 ...

  5. Windows10 Docker镜像加速

    https://dockerhub.azk8s.cn #Azure 中国镜像 https://reg-mirror.qiniu.com #七牛云加速器 https://registry.docker- ...

  6. 2018南京区域赛G题 Pyramid——找规律&&递推

    先手动推出前10项,再上BM板子求出递推式 $A_n = 5A_{n-1} - 10A_{n-2} + 10A_{n-3} - 5A_{n-4} + A_{n-5}$,根据特征根理论可求出特征方程 $ ...

  7. HDU6704 K-th occurrence

    [传送门] 先求出SA和height.然后找到 rank[l] 的 height 值.能成为相同子串的就是和rank[l]的lcp不小于 $len$ 的.二分出左右端点之后,主席树求第k小即可. #i ...

  8. flutter中的异步机制Future

    饿补一下Flutter中Http请求的异步操作. Dart是一个单线程语言,可以理解成物理线路中的串联,当其遇到有延迟的运算(比如IO操作.延时执行)时,线程中按顺序执行的运算就会阻塞,用户就会感觉到 ...

  9. 电商平台+keepalived高可用

    192.168.189.131 电商平台 192.168.189.129 MySQL主192.168.189.130 MySQL备192.168.189.181 VIP 配置MySQL为互为主从并结合 ...

  10. 趋势投资tz-proj springcloud (vue redis)

    https://github.com/deadzq/tz-test-1 https://github.com/deadzq/tz-test-api-1 https://github.com/deadz ...