-
ChatGPT 3 類型 : program 標(biāo)簽 : python
-
1797
用python語言寫一個采集程序,用戶輸入城市名和采集數(shù)量,程序根據(jù)用戶輸入項,采集所在城市的公司信息,信息包括公司名、地址、電話、網(wǎng)址、郵箱、法人和經(jīng)營范圍。程序需要注釋。
整理自網(wǎng)絡(luò)ChatGPT產(chǎn)生之內(nèi)容,文本內(nèi)容不具備參考意義,程序內(nèi)容及代碼片段有且僅有借鑒意義。
請參考下面的代碼:
# coding:utf-8
# 引入需要的第三方模塊
import requests
import re
# 用戶輸入城市名和采集數(shù)量
city = input('請輸入您要查詢的城市:')
number = input('請輸入您要獲取的公司數(shù)量:')
# 定義要采集的url
url = 'http://www.qichacha.com/search?key={}'.format(city)
# 發(fā)送請求獲取相應(yīng)數(shù)據(jù)
response = requests.get(url).text
# 通過正則提取需要的公司信息
companies = re.findall('', response, re.S)
# 初始化一個用來存儲公司信息的字典
result = []
# 遍歷提取的信息
for each in companies[1:int(number)+1]:
# 提取公司名
name = re.findall('data-register_no="(.*?)">', each, re.S)[0]
# 提取公司地址
address = re.findall('data-register_capital="(.*?)"', each, re.S)[0]
# 提取公司電話
tel = re.findall('| (.*?) | \s*?', each, re.S)[0]
# 提取公司法人
legal_person = re.findall('="_blank">(.*?)\s*? | (.*?) | \s*?', each, re.S)[0]
# 將采集的所有信息放入一個字典中
data = {"name":name, "address":address, "tel":tel,
"website":website, "email":email,
"legal_person":legal_person, "business_scope":business_scope}
# 將所有信息的字典放入一個大的字典
result.append(data)
# 打印采集結(jié)果
for each in result:
print(each)
Public @ 2023-02-18 13:12:04 整理自網(wǎng)絡(luò)ChatGPT產(chǎn)生之內(nèi)容,文本內(nèi)容不具備參考意義,程序內(nèi)容有且僅有借鑒意義。
更多您感興趣的搜索
基本
文件
流程
錯誤
SQL
調(diào)試
- 請求信息 : 2026-07-26 09:58:17 HTTP/1.1 GET : www.jilinzikaoedu.com/chatgpt/detail/id/9.html
- 運行時間 : 0.428327s [ 吞吐率:2.33req/s ] 內(nèi)存消耗:5,013.02kb 文件加載:73
- 查詢信息 : 11 queries 1 writes
- 緩存信息 : 0 reads,0 writes
- 配置加載 : 93
- /www/wwwroot/briline.net/public/index.php ( 0.79 KB )
- /www/wwwroot/briline.net/public/public.php ( 1.08 KB )
- /www/wwwroot/briline.net/thinkphp/start.php ( 0.73 KB )
- /www/wwwroot/briline.net/thinkphp/base.php ( 2.66 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Loader.php ( 19.47 KB )
- /www/wwwroot/briline.net/vendor/composer/autoload_namespaces.php ( 0.21 KB )
- /www/wwwroot/briline.net/vendor/composer/autoload_psr4.php ( 0.84 KB )
- /www/wwwroot/briline.net/vendor/composer/autoload_classmap.php ( 0.14 KB )
- /www/wwwroot/briline.net/vendor/composer/autoload_files.php ( 0.42 KB )
- /www/wwwroot/briline.net/vendor/qiniu/php-sdk/src/Qiniu/functions.php ( 7.10 KB )
- /www/wwwroot/briline.net/vendor/qiniu/php-sdk/src/Qiniu/Config.php ( 0.70 KB )
- /www/wwwroot/briline.net/vendor/topthink/think-captcha/src/helper.php ( 1.59 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Route.php ( 59.82 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Config.php ( 6.03 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Validate.php ( 40.27 KB )
- /www/wwwroot/briline.net/vendor/topthink/think-queue/src/config.php ( 0.77 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Console.php ( 21.22 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Error.php ( 3.59 KB )
- /www/wwwroot/briline.net/thinkphp/convention.php ( 10.31 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/App.php ( 21.04 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Request.php ( 50.94 KB )
- /www/wwwroot/briline.net/app/config.php ( 11.25 KB )
- /www/wwwroot/briline.net/app/database.php ( 1.41 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Hook.php ( 4.76 KB )
- /www/wwwroot/briline.net/app/tags.php ( 1.16 KB )
- /www/wwwroot/briline.net/app/common/behavior/InitBase.php ( 8.17 KB )
- /www/wwwroot/briline.net/app/common.php ( 23.29 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Env.php ( 1.25 KB )
- /www/wwwroot/briline.net/thinkphp/helper.php ( 17.86 KB )
- /www/wwwroot/briline.net/app/function.php ( 0.78 KB )
- /www/wwwroot/briline.net/app/extend.php ( 13.29 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Debug.php ( 7.06 KB )
- /www/wwwroot/briline.net/app/common/model/Config.php ( 0.78 KB )
- /www/wwwroot/briline.net/app/common/model/ModelBase.php ( 12.18 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Model.php ( 66.83 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Db.php ( 6.54 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Log.php ( 5.84 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/db/connector/Mysql.php ( 3.94 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/db/Connection.php ( 29.97 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/db/Query.php ( 86.80 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/db/builder/Mysql.php ( 2.16 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/db/Builder.php ( 30.47 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Cache.php ( 6.17 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/cache/driver/File.php ( 7.46 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/cache/Driver.php ( 5.52 KB )
- /www/wwwroot/briline.net/app/common/behavior/InitHook.php ( 1.25 KB )
- /www/wwwroot/briline.net/app/common/model/Hook.php ( 0.77 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Lang.php ( 6.95 KB )
- /www/wwwroot/briline.net/thinkphp/lang/zh-cn.php ( 3.85 KB )
- /www/wwwroot/briline.net/app/route.php ( 0.91 KB )
- /www/wwwroot/briline.net/app/index/config.php ( 0.96 KB )
- /www/wwwroot/briline.net/app/index/common.php ( 0.68 KB )
- /www/wwwroot/briline.net/app/index/controller/Chatgpt.php ( 3.64 KB )
- /www/wwwroot/briline.net/app/index/controller/IndexBase.php ( 1.10 KB )
- /www/wwwroot/briline.net/app/common/controller/ControllerBase.php ( 4.75 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Controller.php ( 6.20 KB )
- /www/wwwroot/briline.net/thinkphp/library/traits/controller/Jump.php ( 4.97 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/View.php ( 6.86 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/view/driver/Think.php ( 5.61 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Template.php ( 46.46 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/template/driver/File.php ( 2.24 KB )
- /www/wwwroot/briline.net/app/index/logic/Chatgpt.php ( 6.09 KB )
- /www/wwwroot/briline.net/app/index/logic/IndexBase.php ( 0.79 KB )
- /www/wwwroot/briline.net/app/common/logic/LogicBase.php ( 0.83 KB )
- /www/wwwroot/briline.net/app/common/model/Chatgpt.php ( 0.78 KB )
- /www/wwwroot/briline.net/app/common/model/ArticleTongji.php ( 0.79 KB )
- /www/wwwroot/briline.net/app/common/model/Article.php ( 0.78 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/paginator/driver/Bootstrap.php ( 5.90 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Paginator.php ( 9.45 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Collection.php ( 8.63 KB )
- /www/wwwroot/briline.net/runtime/temp/2b7d135294f36e3a30d3ef4721b5a040.php ( 57.39 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/Response.php ( 8.64 KB )
- /www/wwwroot/briline.net/thinkphp/library/think/debug/Html.php ( 4.27 KB )
- [ DB ] INIT mysql
- [ CACHE ] INIT File
- [ BEHAVIOR ] Run app\common\behavior\InitBase @app_init [ RunTime:0.007110s ]
- [ BEHAVIOR ] Run app\common\behavior\InitHook @app_init [ RunTime:0.000454s ]
- [ LANG ] /www/wwwroot/briline.net/thinkphp/lang/zh-cn.php
- [ BIND ] 'index'
- [ ROUTE ] array (
'type' => 'module',
'module' =>
array (
0 => 'index',
1 => 'chatgpt',
2 => 'detail',
),
)
- [ HEADER ] array (
'connection' => 'Keep-Alive',
'content-type' => 'application/x-www-form-urlencoded; Charset=UTF-8',
'accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'accept-encoding' => 'gzip, deflate',
'accept-language' => 'zh-CN,zh',
'cookie' => 't=92d7540e476b153862b4ea2356ede7b3; r=8148',
'referer' => 'http://www.baidu.com',
'user-agent' => 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko',
'host' => 'www.jilinzikaoedu.com',
'content-length' => '',
)
- [ PARAM ] array (
'id' => '9',
)
- [ RUN ] app\index\controller\Chatgpt->detail[ /www/wwwroot/briline.net/app/index/controller/Chatgpt.php ]
- [ CACHE ] INIT File
- [ VIEW ] /www/wwwroot/briline.net/public/../app/index/view/chatgpt/detail.html [ array (
0 => 'loading_icon',
1 => 'pjax_mode',
2 => 'static_root',
3 => 'qrcode',
4 => 'seo',
5 => 'catelist',
6 => 'tagslist',
7 => 'moretagslist',
8 => 'art',
9 => 'cate_article_list',
10 => 'tags_article_list',
) ]
- [ DB ] CONNECT:[ UseTime:0.023228s ] mysql:dbname=briline.net;host=106.14.77.182;port=3306;charset=utf8
- [ SQL ] SHOW COLUMNS FROM `ob_chatgpt` [ RunTime:0.016395s ]
- [ SQL ] SELECT * FROM `ob_chatgpt` WHERE `id` = 9 LIMIT 1 [ RunTime:0.015777s ]
- [ EXPLAIN : array (
'id' => 1,
'select_type' => 'SIMPLE',
'table' => 'ob_chatgpt',
'type' => 'const',
'possible_keys' => 'PRIMARY',
'key' => 'PRIMARY',
'key_len' => '4',
'ref' => 'const',
'rows' => 1,
'extra' => NULL,
) ]
- [ SQL ] select * from `ob_article_tongji` where category_id=12 and mark_type='cate' order by times desc limit 15 [ RunTime:0.015916s ]
- [ EXPLAIN : array (
'id' => 1,
'select_type' => 'SIMPLE',
'table' => 'ob_article_tongji',
'type' => 'ALL',
'possible_keys' => NULL,
'key' => NULL,
'key_len' => NULL,
'ref' => NULL,
'rows' => 608,
'extra' => 'Using where; Using filesort',
) ]
- [ SQL ] select * from `ob_article_tongji` where category_id=12 and mark_type='tags' order by times desc limit 100 [ RunTime:0.016072s ]
- [ EXPLAIN : array (
'id' => 1,
'select_type' => 'SIMPLE',
'table' => 'ob_article_tongji',
'type' => 'ALL',
'possible_keys' => NULL,
'key' => NULL,
'key_len' => NULL,
'ref' => NULL,
'rows' => 608,
'extra' => 'Using where; Using filesort',
) ]
- [ SQL ] select * from `ob_article_tongji` where category_id=12 and mark_type='tags' order by rand() limit 30 [ RunTime:0.016581s ]
- [ EXPLAIN : array (
'id' => 1,
'select_type' => 'SIMPLE',
'table' => 'ob_article_tongji',
'type' => 'ALL',
'possible_keys' => NULL,
'key' => NULL,
'key_len' => NULL,
'ref' => NULL,
'rows' => 608,
'extra' => 'Using where; Using temporary; Using filesort',
) ]
- [ SQL ] SELECT * FROM `ob_chatgpt` WHERE `id` = 9 LIMIT 1 [ RunTime:0.015579s ]
- [ EXPLAIN : array (
'id' => 1,
'select_type' => 'SIMPLE',
'table' => 'ob_chatgpt',
'type' => 'const',
'possible_keys' => 'PRIMARY',
'key' => 'PRIMARY',
'key_len' => '4',
'ref' => 'const',
'rows' => 1,
'extra' => NULL,
) ]
- [ SQL ] update `ob_chatgpt` set views=views+2 where id=9 [ RunTime:0.015707s ]
- [ SQL ] SHOW COLUMNS FROM `ob_article` [ RunTime:0.016518s ]
- [ SQL ] SELECT COUNT(*) AS tp_count FROM `ob_article` WHERE `category_id` = 12 AND `cate` = 'program' AND `status` <> -1 LIMIT 1 [ RunTime:0.021754s ]
- [ EXPLAIN : array (
'id' => 1,
'select_type' => 'SIMPLE',
'table' => 'ob_article',
'type' => 'ALL',
'possible_keys' => NULL,
'key' => NULL,
'key_len' => NULL,
'ref' => NULL,
'rows' => 9562,
'extra' => 'Using where',
) ]
- [ SQL ] SELECT * FROM `ob_article` WHERE `category_id` = 12 AND `cate` = 'program' AND `status` <> -1 ORDER BY rand() LIMIT 0,2 [ RunTime:0.031172s ]
- [ EXPLAIN : array (
'id' => 1,
'select_type' => 'SIMPLE',
'table' => 'ob_article',
'type' => 'ALL',
'possible_keys' => NULL,
'key' => NULL,
'key_len' => NULL,
'ref' => NULL,
'rows' => 9562,
'extra' => 'Using where; Using temporary; Using filesort',
) ]
- [ SQL ] SELECT COUNT(*) AS tp_count FROM `ob_article` WHERE `category_id` = 12 AND `tags` = 'python' AND `status` <> -1 LIMIT 1 [ RunTime:0.022294s ]
- [ EXPLAIN : array (
'id' => 1,
'select_type' => 'SIMPLE',
'table' => 'ob_article',
'type' => 'ALL',
'possible_keys' => NULL,
'key' => NULL,
'key_len' => NULL,
'ref' => NULL,
'rows' => 9562,
'extra' => 'Using where',
) ]
- [ SQL ] SELECT * FROM `ob_article` WHERE `category_id` = 12 AND `tags` = 'python' AND `status` <> -1 ORDER BY rand() LIMIT 0,2 [ RunTime:0.031642s ]
- [ EXPLAIN : array (
'id' => 1,
'select_type' => 'SIMPLE',
'table' => 'ob_article',
'type' => 'ALL',
'possible_keys' => NULL,
'key' => NULL,
'key_len' => NULL,
'ref' => NULL,
'rows' => 9562,
'extra' => 'Using where; Using temporary; Using filesort',
) ]

0.431243s
|