27,04,2017
|
Jason |
在网上找到一篇《python调用中国天气网的公用API获取天气信息 》它的源码是这样的:
#! /usr/bin/python
# coding = utf-8
# ToDo: get weather info from weather.com.cn
# Author: Steven
# Date: 2013/05/13
import urllib2
import json
# get weather html and parse to json
weatherHtml = urllib2.urlopen('http://m.we ...
26,04,2017
|
Jason |
https://www.codeproject.com/Articles/1160315/Web-scraping-with-Python-Part-I
https://www.codeproject.com/Articles/1089134/Making-GET-Requests-in-Python-Tutorial
https://www.codeproject.com/Tips/819508/Python-Dictionary-get-method
https://www.codeproject.com/Tips/993605/Lambda-Expressions-in-Python
https://www.codeproject.com/Articles/639887/Calli ...
26,04,2017
|
Jason |
My journey as a web developer started back in 2000 right at the age of 21 and I can clearly remember a certain characteristic of those days in terms of how they made me feel. The best term I could find to describe that feeling is… joy.
I didn’t worry about things like time, deadlines or priorities or even productivity. The one thing I was concerned with was learning, as muc ...
26,04,2017
|
Jason |
首先注册一个ip138账号并登陆,获得Token。然后进入IP查询—文档—代码示例页面,找到“Python调用iP查询接口示例”,获得代码:
#!/usr/bin/python
# -*- coding: utf-8 -*-
#python3
import httplib2, urllib
params = urllib.urlencode({'ip':'9.8.8.8','datatype':'jsonp','callback':'find'})
url = 'http://api.ip138.com/query/?'+params
headers = {"token":"8594766483a2d65d ...
25,04,2017
|
Jason |
今天 在执行下面这段代码的时候,
#!/usr/bin/env python
#
# ______ _ _ ______ _ ______ _
#(_____ | | | | (______) | | / _____) |
# _____) )__ _ _ _ _____ ____ _____ __| | | |__ _ _ _ _ _____ ____| | _ ( (___ ...
24,04,2017
|
Jason |
首先,json的格式:
www.tuling123.com/openapi/api?key=$api_key&info=$req_info
import json
import requests
import urllib
import urllib2
KEY = '***********************' # change to your API KEY
url = 'http://www.tuling123.com/openapi/api'
req_info = u'讲个笑话'.encode('utf-8')
query = {'key': KEY, 'info': req_info}
headers = {'Content-type': 'text/html', 'charset': 'ut ...
22,04,2017
|
Jason |
到上一教程为止,我们已经建立好一个博客的框架,但是只有一个主页,我们在网络上看到的博客,一般首页是一个文章页表,并显示文章的部分内容,点击文章标题就会跳转到文章详细页面。下面我们就来实现这一功能。
现在修改my_blog/article/views.py代码,在文件中添加如下的代码:
from django.http import Http404
def detail(request, id):
try:
post = Article.objects.get(id=str( ...
22,04,2017
|
Jason |
1、建立第一个模板
在template文件夹下增加base.html, 并在其中增加如下代码
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A layout example that shows off a blo ...
22,04,2017
|
Jason |
一、了解Django程序的逻辑
1、先来说说我们上网时,网页是如何呈现在我们屏幕上的:
通过浏览器向服务器发出request请求->从服务器获取数据->服务器处理数据->把网页呈现出来。
Django中的url设置相当于客户端向服务器发出request请求的入口, 并用来指明要调用的程序逻辑
Django中的views用来处理程序逻辑, 然后呈现到template(一般为GET方法, POST方法略有不同)
Django中的template一般为html+C ...
22,04,2017
|
Jason |
一、创建models
打开my_blog/article/models.py文件,将下面的代码添加到文件的末尾:
class Article(models.Model) :
title = models.CharField(max_length = 100) #博客题目
category = models.CharField(max_length = 50, blank = True) #博客标签
date_time = models.DateTimeField(auto_now_add = True) #博客日期
content = models.TextField(blank = True, null = True) ...
Page: 132 of 216 1 ...
130 131 132 133 134 ...
216