使用 AWS Lambda 抓取网站并将数据保存在 S3 上。
当我执行 Lambda 时,出现以下错误消息。
{“errorMessage”:“无法导入模块“lambda_function”:无法从“urllib3.util.ssl_”(/opt/python/urllib3/util/ssl_.py)导入名称“DEFAULT_CIPHERS””,“errorType”:“运行时.ImportModuleError", "requestId": "fb66bea9-cbad-4bd3-bd4d-6125454e21be", "stackTrace": [] }
最小 Lambda 代码如下。
import requests
import boto3
def lambda_handler(event, context):
s3 = boto3.client('s3')
upload_res = s3.put_object(Bucket='horserace-dx', Key='/raw/a.html', Body='testtext')
return event
Run Code Online (Sandbox Code Playgroud)
Lambda 上添加了一层。使用以下命令将文件保存在python文件夹中,冻结在 zip 文件中,然后作为层上传到 AWS Lambda。
!pip install requests -t ./python --no-user
!pip install pandas -t ./python --no-user
!pip install beautifulsoup4 -t ./python --no-user
Run Code Online (Sandbox Code Playgroud)
horserace-dx已存在raw存在我搜索“无法从‘urllib3.util.ssl_’导入名称‘DEFAULT_CIPHERS’”并找到了一些建议。我用以下代码制作了图层,然后再次尝试,但没有成功。
!pip install …Run Code Online (Sandbox Code Playgroud) gem "jekyll-remote-theme"bundle exec jekyll servegem "jekyll-remote-theme".我正在尝试使用Jekyll和Minimal Mistakes在GitHub页面中构建一个博客.在我推动更改之前,我想检查页面是否一切正常.
bundle exec jekyll new . --forcebundle exec jekyll serve我有一个与之相关的错误libcurl.dll.以下是Powershell上的消息.
依赖性错误:哎呀!看起来您没有安装jekyll-remote-theme或其依赖项.为了使用当前配置的Jekyll,您需要安装此gem.来自Ruby的完整错误消息是:'无法打开库'libcurl':(非法字符).无法打开libr ary'libcurl.dll':(非法字符).无法打开库'lib curl.so.4':(非法字符).无法打开库'libcurl.so .4.dll':(非法字符)'如果遇到麻烦,可以在https://jekyllrb.com/help/找到有用的资源!
我按照GitHub页面依赖关系中的说明缺失·问题#17·benbalter/jekyll-remote-theme,问题解决了.
然后出现了另一个错误bundle exec jekyll serve.本地创建的页面为空白.http://127.0.0.1:4000/什么也没说.
PS E:\workspace\mysite\dixhom.github.io> bundle exec jekyll serve
Configuration file: E:/workspace/mysite/dixhom.github.io/_config.yml
Source: E:/workspace/mysite/dixhom.github.io
Destination: E:/workspace/mysite/dixhom.github.io/_site
Incremental build: disabled. Enable with --incremental
Generating... …Run Code Online (Sandbox Code Playgroud) 以后在MSYS2中找不到一些主要命令update-core.
我将MSYS2引入了我的计算机并执行了update-core.但是,更新后,当我键入pacman或update-core,终端说bash: pacman: command not found.我重新启动了MSYS2并尝试了相同的过程,但结果是一样的.我重新安装了MSYS2并尝试了相同的过程,但结果是一样的.我想把事情做对,但不知道怎么做.
任何建议将不胜感激.谢谢.
在下面的网页上搜索二手车数据.
http://www.goo-net.com/php/search/summary.php?price_range=&pref_c=08,09,10,11,12,13,14&easysearch_flg=1
刮掉整个页面.在上面的网址中,只显示了前30个项目.这些可能会被我写的下面的代码所刮掉.其他页面的链接显示为1 2 3 ...但链接地址似乎是在Javascript中.我搜索了有用的信息,但找不到任何信息.
from bs4 import BeautifulSoup
import urllib.request
html = urllib.request.urlopen("http://www.goo-net.com/php/search/summary.php?price_range=&pref_c=08,09,10,11,12,13,14&easysearch_flg=1")
soup = BeautifulSoup(html, "lxml")
total_cars = soup.find(class_="change change_01").find('em').string
tmp = soup.find(class_="change change_01").find_all('span')
car_start, car_end = tmp[0].string, tmp[1].string
# get urls to car detail pages
car_urls = []
heading_inners = soup.find_all(class_="heading_inner")
for heading_inner in heading_inners:
href = heading_inner.find('h4').find('a').get('href')
car_urls.append('http://www.goo-net.com' + href)
for url in car_urls:
html = urllib.request.urlopen(url)
soup = BeautifulSoup(html, "lxml")
#title
print(soup.find(class_='hdBlockTop').find('p', class_='tit').string)
#price of car itself
print(soup.find(class_='price1').string)
#price of car including …Run Code Online (Sandbox Code Playgroud) 我一直在使用Progress<T>,想知道是否可以将其替换Action<T>。
在下面的代码中,使用它们中的每个来报告进度(即ReportWithProgress()或)ReportWithAction()对我没有任何明显的影响。如何progressBar1增加字符串,如何将字符串写入输出窗口,它们看起来是相同的。
// WinForm application with progressBar1
private void HeavyIO()
{
Thread.Sleep(20); // assume heavy IO
}
private async Task ReportWithProgress()
{
IProgress<int> p = new Progress<int>(i => progressBar1.Value = i);
for (int i = 0; i <= 100; i++)
{
await Task.Run(() => HeavyIO());
Console.WriteLine("Progress : " + i);
p.Report(i);
}
}
private async Task ReportWithAction()
{
var a = new Action<int>(i => progressBar1.Value = i);
for (int i …Run Code Online (Sandbox Code Playgroud) 我正在尝试将时间戳字符串转换为TimeSpan对象.但是,TimeSpan.Parse()不能像我期望的那样工作.我会解释原因.
我想转换两种类型的时间戳.
30:53,1:23,0:051:30:53,2:1:23,0:0:3问题是,类型1在TimeSpan.Parse()方法中被解释为小时:分钟格式.
Console.WriteLine(TimeSpan.Parse("12:43"));
// the result I expect -> 0:12:43
// the actual result -> 12:43:00
Run Code Online (Sandbox Code Playgroud)
我搜索了这个问题并发现了这个SO帖子.
将HH.mm格式的字符串解析为TimeSpan
这用于DateTime.ParseExact()以特定格式解析字符串.但是,问题是我需要为类型1和2使用不同的格式.
// ok
var ts1 = DateTime.ParseExact("7:33", "m:s", CultureInfo.InvariantCulture).TimeOfDay;
// throws an exception
var ts2 = DateTime.ParseExact("1:7:33", "m:s", CultureInfo.InvariantCulture).TimeOfDay;
// throws an exception
var ts3 = DateTime.ParseExact("7:33", "h:m:s", CultureInfo.InvariantCulture).TimeOfDay;
// ok
var ts4 = DateTime.ParseExact("1:7:33", "h:m:s", CultureInfo.InvariantCulture).TimeOfDay;
Run Code Online (Sandbox Code Playgroud)
我也查了MSDN,但没用.
https://msdn.microsoft.com/ja-jp/library/se73z7b9(v=vs.110).aspx …
当我这样做时pip install sklearn --upgrade,我收到以下错误:
Exception:
Traceback (most recent call last):
File "d:\anaconda3\lib\site-packages\pip\basecommand.py", line 209, in main
status = self.run(options, args)
File "d:\anaconda3\lib\site-packages\pip\commands\install.py", line 317, in run
prefix=options.prefix_path,
File "d:\anaconda3\lib\site-packages\pip\req\req_set.py", line 732, in install
**kwargs
File "d:\anaconda3\lib\site-packages\pip\req\req_install.py", line 835, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "d:\anaconda3\lib\site-packages\pip\req\req_install.py", line 1030, in move_wheel_files
isolated=self.isolated,
File "d:\anaconda3\lib\site-packages\pip\wheel.py", line 344, in move_wheel_files
clobber(source, lib_dir, True)
File "d:\anaconda3\lib\site-packages\pip\wheel.py", line 322, in clobber
shutil.copyfile(srcfile, destfile)
File "d:\anaconda3\lib\shutil.py", line 115, …Run Code Online (Sandbox Code Playgroud)