http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 8885|回复: 0

[Python3教程] Python3教程之requests使用方法

[复制链接]
发表于 2021-8-21 14:59:18 | 显示全部楼层 |阅读模式
首先我们找到File---New Projects Setup--Settings for New Projuect....
下载.png

这里就相当于c#里面的添加Dll的引用

然后这个时候就可以直接导入requests了
[C#] 纯文本查看 复制代码
import requests


假如我们现在要访问网站http://www.sufeinet.com
代码如下
[C#] 纯文本查看 复制代码
    url = 'http://www.sufeinet.com'
    strhtml = requests.get(url)  # Get方式获取网页数据
    print(strhtml.text)


这个代码量确实 比C#要少挺多的,
执行一下看看
[C#] 纯文本查看 复制代码
D:\Users\sufei\PycharmProjects\pythonProject\venv\Scripts\python.exe d:/Users/sufei/PycharmProjects/pythonProject/main.py
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>C#爬虫技术-C#源码-C#HttpHelper万能框架-分布式框架-苏飞论坛</title>
<meta name="keywords" content="Httphelper,万能框架,C#,苏飞论坛,分布式框架,c#源码,c#论坛,httphelper类,httphelper,C#教程" />
<meta name="description" content="C#程序员论坛、网络爬虫论坛,一个源码开源、开放的网上论坛。C#HtttpHelper、C#基类库、Httphelper万能框架、分布式框架,也可以亲切的叫它苏飞论坛。 " />
<meta name="generator" content="Discuz! X3.4" />
<meta name="author" content="Discuz! Team and Comsenz UI Team" />
<meta name="copyright" content="2001-2017 Comsenz Inc." />
<meta name="MSSmartTagsPreventParsing" content="True" />
<meta http-equiv="MSThemeCompatible" content="Yes" />
<base href="http://www.sufeinet.com/" /><link rel="stylesheet" type="text/css" href="data/cache/style_25_common.css?a0z" /><link rel="stylesheet" type="text/css" href="data/cache/style_25_forum_index.css?a0z" /><script type="text/javascript">var STYLEID = '25', STATICURL = 'static/', IMGDIR = 'static/image/common', VERHASH = 'a0z', charset = 'gbk', discuz_uid = '0', cookiepre = 'ecax_2132_', cookiedomain = '', cookiepath = '/', showusercard = '1', attackevasive = '0', disallowfloat = 'login|newthread', creditnotice = '1|威望|,2|金钱|,3|贡献|,4|人民币|', defaultstyle = '', REPORTURL = 'aHR0cDovL3d3dy5zdWZlaW5ldC5jb20v', SITEURL = 'http://www.sufeinet.com/', JSPATH = 'data/cache/', CSSPATH = 'data/cache/style_', DYNAMICURL = '';</script>
<script src="data/cache/common.js?a0z" type="text/javascript"></script>
<meta name="application-name" content="苏飞论坛" />
<meta name="msapplication-tooltip" content="苏飞论坛" />
<meta name="msapplication-task" content="name=主页;action-uri=http://www.sufeinet.com/forum.php;icon-uri=http://www.sufeinet.com/static/image/common/bbs.ico" />
<link rel="archives" title="苏飞论坛" href="http://www.sufeinet.com/archiver/" />
<script src="data/cache/forum.js?a0z" type="text/javascript"></script>
</head>

<body id="nv_forum" class="pg_index">
<div id="append_parent"></div><div id="ajaxwaitid"></div>
<div id="toptb" class="cl">
<div class="wp">
<div class="z"><a href="javascript:;" >设为首页</a><a href="http://www.sufeinet.com/" >收藏本站</a></div>
<div class="y">
<a id="switchblind" href="javascript:;" title="开启辅助访问" class="switchblind">开启辅助访问</a>
<a href="http://www.sufeinet.com/about/dv.aspx" target="_blank"  style="font-weight: bold;">广告合作</a><a href="http://www.sufeinet.com/plugin.php?id=keke_group" target="_blank"  style="font-weight: bold;">开通会员</a><a href="thread-1779-1-1.html"  style="font-weight: bold;color: red">官方QQ/微信群</a><a href="thread-366-1-1.html" title="新人来这里报个到吧" target="_blank"  style="font-weight: bold;">新人报到处</a></div>
</div>
</div>

<div id="qmenu_menu" class="p_pop blk" style="display: none;">
<div class="ptm pbw hm">
请 <a href="javascript:;" class="xi2"><strong>登录</strong></a> 后使用快捷导航<br />没有帐号?<a href="member.php?mod=register" class="xi2 xw1">马上注册</a>
</div>
<div id="fjump_menu" class="btda"></div></div><div class="wp a_h"><div><a href="http://i0k.cn/4T3YN" target="_blank"><img src="http://www.sufeinet.com/dv/dv/dailiip.jpg" border="0"></a></div></div>
<div id="hd">
<div class="wp">
<div class="hdc cl"><h2><a href="http://www.sufeinet.com/" title="苏飞论坛"><img src="template/veikei_dz_life_20130810_plus/images/logo.png?20160602" alt="苏飞论坛" border="0" /></a></h2><script src="data/cache/logging.js?a0z" type="text/javascript"></script>
<form method="post" autocomplete="off" id="lsform" action="member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes">
<div class="fastlg cl">
<span id="return_ls" style="display:none"></span>


由于页面过长,我只输出了一部分大家知道怎么回事就行了



1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2024-6-17 15:16

© 2014-2021

快速回复 返回顶部 返回列表