前提需要安装scrapy 这个框架爬取公司简介1.scrapy shell http://static.wealthbetter.com/about2.response.xpath ('//dl[@class="a_about_item clearfix"]/dd/text()').extract() //匹配任意节点是dl带class的文字 爬取公司动态信息1.http:...
前提需求在本地环境创建stock库和sina_news表import datetimeimport urllib.requestimport pymysqlfrom bs4 import BeautifulSoup#如果没有安装好BeautifulSoup,这里是会报错的#自定义一个函数拿到博客的链接def getUrl (url): #定义一个headers,存储刚才...
import os import time import tushare as ts import pandas as pd def check(code, low, high): global e df = ts.get_realtime_quotes(code) e = df[['code','name','price','time']] p = df[u'
x
import urllib.requestfrom bs4 import BeautifulSoup#如果没有安装好BeautifulSoup,这里是会报错的#自定义一个函数拿到博
# 建立数据库连接,剔除已入库的部分db = pymysql.connect(host='127.0.0.1', user='root', passwd='', db='test', charset='utf8')cursor = db.cursor()dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")sql_inse...
import osimport reimport sysimport urllibimport urllib.request#在python3.x中没有urllib2,必须使用此语句from urllib import request from bs4 import BeautifulSoupimport requests #Beautiful Soup是一个...
import osimport timeimport tushare as tsimport pandas as pdimport smtplibfrom email.mime.text import MIMETextdef check(code, low, high): global e df = ts.get_realtime_quotes(code) ...
前提是需要在本地配置好python的运行环境,然后在需要在php的运行环境中将python的这个文件放在所在的目录下,用Python命令执行没问题的花,就可以执行了header("Content-Type: text/html; charset=UTF-8 ");$output = shell_exec('python h.py');...
import os,sysimport pandas as pdimport numpy as npimport datetimeimport pandas_datareader.data as webimport mathimport matplotlib.pyplot as pltfrom matplotlib import stylefrom sklearn.model_se...
1.说明写个脚本帮你每天盯着某几支股票,达到预设值时响铃提醒。这是最简单的股票应用,虽然谈不上智能,但是自动化――老盯着就容易冲动操作。本例中实现了每5秒取一次股票数据,并在上证指数高于3200点,或601318低于49元时响提醒。2.程序import osimport timeimport tushare as tsimport pandas as pd...
django-admin startproject HelloWorld 创建项目在settings.py 文件下
Copyright © 2005-2024 51CTO.COM 版权所有 京ICP证060544号