构建node.js基础镜像_我如何使用Node.js构建工作抓取网络应用
构建node.js基础镜像
by Oyetoke Tobi Emmanuel
由Oyetoke Tobi Emmanuel
我如何使用Node.js构建工作抓取网络应用 (How I built a job scraping web app using Node.js)
Scraping jobs from the web has now become easier thanks to Indreed.
现在,借助Indreed,从网上抓取工作变得更加容易。
关于Indreed (About Indreed)
Indreed is a Rest API for scraping jobs from Indeed and around the web. It is powered by my personal web scraping project and layered on a rest API. Its a real Rest API and can be used from any platform using any programming language. It has support for CORs so you can use it from external web pages. Indreed supports a wide range of filters that you can use to fine tune your job results. With Indreed, you can get almost all the information you need about a job around the web. The docs can be found here.
Indreed是一个Rest API,用于从确实和网络上抓取作业。 它由我的个人Web抓取项目提供支持,并位于其他API上。 它是真正的Rest API,可以在使用任何编程语言的任何平台上使用。 它支持COR,因此您可以从外部网页使用它。 Indreed支持多种过滤器,您可以使用它们来微调您的工作结果。 使用Indreed,您几乎可以获得有关网络工作所需的所有信息。 该文档可以在这里找到。
构建Web应用 (Building the Web App)
For this tutorial, we’ll be using Node.js to build a job listing web app. The technology stack we are going to use includes:
在本教程中,我们将使用Node.js构建工作清单Web应用程序。 我们将使用的技术栈包括:
Axios for performing Rest API calls
用于执行Rest API调用的Axios
Express for the server
快递服务器
Handlebars for the template language.
模板语言的车把 。
And yes, we’ll be using MDL for our UI/UX.
是的,我们将在UI / UX中使用MDL 。
Let’s begin…
让我们开始…
Open your terminal:
打开您的终端:
mkdir jobby && cd jobbynpm init -ynpm install --save express axios express-handlebarsnpm install --save-dev nodemon
Once you’ve done that, open the created package.json
file in your preferred text editor and you should see something like below:
完成此操作后,在首选的文本编辑器中打开创建的package.json
文件,您将看到以下内容:
I already added a description, pointed my main to app.js
, and I added keywords, my name and also nodemon for live reloading.
我已经添加了一个描述,将主要内容指向app.js
,还添加了关键字,我的名字以及用于实时重新加载的nodemon。
Now let’s setup a basic express server and the handlebars templating engine. Create app.js
file in your project directory:
现在,让我们设置一个基本的Express服务器和车把模板引擎。 在您的项目目录中创建app.js
文件:
Make sure you have the same folder structure like below:
确保您具有相同的文件夹结构,如下所示:
Now we need to create a index.hbs
file in the views folder that will hold our HTML:
现在我们需要在views文件夹中创建一个index.hbs
文件,该文件将保存我们HTML:
To run the app, you can basically use node app.js
. In case you want to use nodemon, you can do nodemon app.js
.
要运行该应用程序,您基本上可以使用node app.js
如果要使用nodemon,可以执行nodemon app.js
You can now open http://localhost:5000
in your browser.
您现在可以在浏览器中打开http://localhost:5000
。
Hurray!
欢呼!
Now lets try getting jobs from the Indreed API using axios, then using handlebars to format it.
现在,让我们尝试使用axios从Indreed API中获取作业,然后使用把手对其进行格式化。
Open the app.js
and update the app.get("/")
:
打开app.js
并更新app.get("/")
:
Then replace {{ body }}
with the below:
然后,将{{ body }}
替换为以下内容:
<div class="mdl-grid portfolio-max-width">{{# each jobs }} <div class="mdl-cell mdl-card mdl-shadow--4dp portfolio-card"> <div class="mdl-card__media"></div> <div class="mdl-card__title"> <h2 class="mdl-card__title-text">{{ this.title }}</h2> </div> <div class="mdl-card__supporting-text"> {{ this.summary }} </div> <div class="mdl-card__actions mdl-card--border"> <a class="mdl-button mdl-button--colored mdl-js-button mdl-js- ripple-effect mdl-button--accent" href="{{ this.url }}">Read more</a> </div> </div>{{/each}}</div>
Note: For this, we are only displaying title
, summary
and url
. There is other information you can add, so check that out.
注意 :为此,我们仅显示title
, summary
和url
。 您还可以添加其他信息,因此请检查一下。
Refresh it and you will be wowed:
刷新它,您会惊叹:
Congratulations, you just built a simple job listing web app.
恭喜,您刚刚构建了一个简单的职位列表网络应用。
Let’s break down what we just built:
让我们分解一下我们刚刚构建的内容:
We sent a
GET
request to the Indreed API usingaxios
我们使用
axios
将GET
请求发送到Indreed API- this fetched the web developer job listings这获取了Web开发人员的工作清单
- and returned JSON data we passed into handlebars to help us loop through it并返回JSON数据,我们将其传递到把手中以帮助我们循环遍历它
- the results are displayed.结果显示出来。
Our app is just showing web developer
jobs. What if we wanted to see other types of jobs? It would be silly to go change it from the code side. So what we are going to do next is create a simple form to filter job results.
我们的应用程序仅显示web developer
工作。 如果我们想看到其他类型的工作该怎么办? 从代码方面进行更改很愚蠢。 因此,我们接下来要做的是创建一个简单的表单来过滤作业结果。
Lets create a /search
endpoint:
让我们创建一个/search
端点:
Next, create search.hbs
:
接下来,创建search.hbs
:
Let’s add some CSS though:
让我们添加一些CSS:
Next, update your homepage template with this:
接下来,使用以下命令更新您的主页模板:
Now that we are done with the templates, let’s go clean up our app.js
:
现在我们已经完成了模板的工作,让我们清理一下app.js
:
That’s it, we are done.
就是这样,我们完成了。
一些建议 (Some Suggestions)
Location: The app detecting the user’s location is something you can add to make Indreed smarter. I’d suggest that you use Express-IP, an express middleware for getting IP information. You can use it as below:
位置 :您可以添加检测用户位置的应用程序,以使Indreed变得更智能。 我建议您使用Express-IP ,这是一种用于获取IP信息的快速中间件。 您可以按以下方式使用它:
req.ipInfo
might return null if you are on localhost (that’s why the if statement is there).
如果您在localhost上,则req.ipInfo
可能返回null(这就是if语句存在的原因)。
2. Advanced Search Results: Indreed has a variety of filters you can use to filter your job results, and we’ve only used the q
and l
. So you can add a form that utilizes some of the available filters:
2. 高级搜索结果 :Indreed有多种过滤器可用于过滤您的工作结果,并且我们仅使用了q
和l
。 因此,您可以添加一个利用一些可用过滤器的表单:
3. Authentication: You can add an authentication system to personalize search results for the user. With this, users can select the categories of jobs they’d like to see, and you’ll continue to suggest jobs relating to that when they log in.
3. 身份验证 :您可以添加身份验证系统来个性化用户的搜索结果。 这样,用户可以选择他们想要查看的工作类别,并且您将在登录时继续建议与此工作相关的工作。
4. Cache: If you want to personalize search results for a user without going through Authentication, you can opt in for Cache.
4. 缓存:如果您不通过身份验证即可个性化用户的搜索结果,则可以选择使用缓存。
简短说明 (Short Note)
I am the creator of the Indreed API, and its currently in its Alpha stage. As you can see, its hosted on Heroku and still needs lot of improvement in terms of structuring, performance, speed and hosting. To make this go forward, you can contribute to the development by contacting me (oyetoketoby80[at]gmail.com) or you can also help through my patreon page. http://patreon.com/oyetoketoby
我是Indreed API的创建者,它目前处于Alpha阶段。 如您所见,它托管在Heroku上,并且在结构,性能,速度和托管方面仍需要大量改进。 为此,您可以通过与我联系(oyetoketoby80 [at] gmail.com)来为开发做出贡献,或者也可以通过我的patreon页面提供帮助。 http://patreon.com/oyetoketoby
That’s all for this article. You can get the code from here and also view the live demo: http://jobbyio.herokuapp.com.
这就是本文的全部内容。 您可以从此处获取代码,还可以观看实时演示: http : //jobbyio.herokuapp.com 。
If you enjoyed this article, kindly clap and share to others.
如果您喜欢这篇文章,请拍手并与他人分享。
翻译自: https://www.freecodecamp.org/news/how-i-built-a-job-scraping-web-app-using-node-js-and-indreed-7fbba124bbdc/
构建node.js基础镜像
相关文章:

Robotium测试报告的生成方法(上)
7.1 使用junit-report生成报告 这个是参考网上的:http://www.xuebuyuan.com/2148574.html,经我个人验证是可行的方法,网上写的挺详细的,不过有些不太清楚明白的地方,鉴于网上说的有点迷茫,所以下面我再细化…

Python之向日志输出中添加上下文信息
除了传递给日志记录函数的参数(如msg)外,有时候我们还想在日志输出中包含一些额外的上下文信息。比如,在一个网络应用中,可能希望在日志中记录客户端的特定信息,如:远程客户端的IP地址和用户名。…

小程序点击图片自动播放视频,停止上一个视频播放
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 通过列表的点击事件自动播放列表对应的视频,同时停止上一个视频的播放 源码: <view><view classvv wx:for{{vedio_data}} wx:key><view classblock stylemargin…

hitchhiker部署_Hitchhiker的React Router v4指南:无限远的递归路径!
hitchhiker部署Welcome to the third part of the Hitchhiker’s Guide to React Router v4. In this article we’re going to focus on recursive paths. If you’ve missed the first two parts, you can find part 1 here and part 2 here.欢迎阅读《 Hitchhiker React Rou…

smbpasswd 和 pdbedit 的区别
smbpasswd 和 pdbedit 的区别 以前我们在windows上共享文件的话,只需右击要共享的文件夹然后选择共享相关的选项设置即可。然而如何实现windows和linux的文件共享呢?这就涉及到了samba服务了,这个软件配置起来也不难,使用也非常简…

DB天气app冲刺二阶段第十一天(完结)
今天最后一天冲刺了,明天就不再冲刺了。。已经把所有的技术的问题还有设计的问题都弄好了吧应该说 至少目前来说是的。因为有的实现不了的或者需要耗费时间的已经果断舍弃了,然后需要完善的也都基本完善了。 现在还需要做的就是素材的收集整理。需要抽半…

如何超越console.log并充分利用浏览器的调试控制台
by Gilad Dayagi通过吉拉德达亚吉 The console object is a very useful feature of browsers that has been around for many years. It provides access to the browser’s debugging console.Most web developers know how to print messages to the console using console…

区域设置 ID (LCID) 表, 及获取方法
区域设置 ID (LCID) 表, 及获取方法 中国的区域设置 ID 是 2052, 如果经常打开微软软件的安装目录应该经常见到.获取很简单, 有现成的 API 函数: GetThreadLocale.beginShowMessage(IntToStr(GetThreadLocale)); //2052 end; 区域设置 ID (LCID) 表区域设置描述简写十六进制值十…

E201700525-hm
skeleton n. 骨骼; (建筑物等的) 骨架; 梗概; 骨瘦如柴的人(或动物);adj. 骨骼的; 骨瘦如柴的; 概略的; 基本的; cloud n. 云; 云状物; invoke vt. 乞灵,祈求; 提出或授引…以支持或证明; 召鬼; 借助;render …

php不显示报错
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 error_reporting(E_ALL & ~E_NOTICE);

致谢 开源开发者的贡献_对开源做出的贡献如何使我成为更好的开发人员,以及如何做到这一点...
致谢 开源开发者的贡献by Luciano Strika通过卢西亚诺斯特里卡(Luciano Strika) 对开源做出的贡献如何使我成为更好的开发人员,以及如何做到这一点 (How contributing to open source made me a better developer — and how you can do it, too) So you’ve been …

欲精一行,必先通十行
将前端开发和服务器端开发做一个比较,前端开发没有服务器端开发“深”,服务器端开发没有前端开发“广”。经常听到做前端的同行抱怨需要学的东西太 多,东学一点西学一点,什么都会,但也什么都不精。很直接的结果就是沦为…

LeetCode 228: Summary Ranges
Given a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"]. 代码要求对数组中的元素进行分段。 首先给出字符串格式化函数,假设be…

JQ+ajax 提交表单不跳转页面
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 代码 <div class"apply_box"><h1>合作申请</h1><div class"apply_l"><input type"text" maxlength"20" id"name" name&q…

node.js是开源的吗_为开源做贡献并不难:我为Node.js项目做贡献的旅程
node.js是开源的吗As a developer, you should consider contributing to open source software. Many of your potential employers will look favorably on these contributions.作为开发人员,您应该考虑为开源软件做贡献。 您的许多潜在雇主将对这些供款看好。 …

超级简单的jquery轮播图demo
<!DOCTYPE html> <html><head><meta charset"UTF-8"><title>轮播图demo</title><script type"text/javascript" src"js/jquery-3.2.1.slim.js" ></script><link rel"stylesheet" …

Mysql 操作技巧
复制表结构 表数据Mysql> create tables t2 like t1;Mysql> insert into t2 select * from t1; mysql 索引a、Alert Table 用来创建普通索引、Unique 唯一索引 (当前列数值不可重复) 或 Primary Key 主键索引Mysql> alter table table_name add index index_name(col…

JS实现复制到剪切板效果
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 代码: <!DOCTYPE html> <html lang"en"><head><meta http-equiv"Content-Type" content"text/html; charsetutf-8" /><meta cha…

如何管理多个Python版本和虚拟环境
Addition January 2019: If you are coming back to this blog after upgrading to macOS Mojave please see this github issue for a solution to the common pyenv ‘zlib not available’ problem.此外,2019年1月:如果在升级到macOS Mojave之后又回到…

linux 下byte,char,unsigned char的区别
在linux中,对byte的定义为无符号char,而char默认为有符号char。 #ifndef BYTE #define BYTE unsigned char #endif以下ZZ百度知道: 在C中,默认的基础数据类型均为signed,现在我们以char为例,说明(signed) c…

词法作用域和动态作用域
JavaScript采用的是词法作用域 1.词法作用域 即函数定义时,即确定的作用域。js中的作用域链,在函数声明时候,就已经确定了,无论函数在何处调用,其作用域变量的查找都是按照定义是包含关系去查找。 2.动态作用域 变量的…

10-18 JS基础复习笔记
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 1.JS类型 Numbel String Boolean Symbol Null Undefined Object(Funtion,Array,Data,Regexp); 2.字符串转数字类型 "122" //122 var a 1 2; console.log(a) //3 3.null 和 u…

vue.js crud_如何使用VS Code和ADO.NET使用ASP.NET Core执行CRUD操作
vue.js crud介绍 (Introduction) In this article we are going to create a web application using ASP.NET Core MVC with the help of Visual Studio Code and ADO.NET. We will be creating a sample Employee Record Management System and performing CRUD operations on…
redis事物命令示例
命令示例: 1. 事务被正常执行:#在Shell命令行下执行Redis的客户端工具。/> redis-cli#在当前连接上启动一个新的事务。redis 127.0.0.1:6379>multiOK#执行事务中的第一条命令,从该命令的返回结果可以看出,该命令并没有立即执…

JS 函数 函数递归
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 重要:函数也是对象,你可以给它们添加属性或者更改它们的属性。 函数内部对象:arguments 解析:函数实际上是访问了函数体中一个名为 arguments 的内部对象…

swift设置启动图不现实_如何通过装饰房屋来开始在Swift中使用增强现实
swift设置启动图不现实by Ranadhir Dey由Ranadhir Dey 如何通过装饰房屋来开始在Swift中使用增强现实 (How to get started with augmented reality in Swift by decorating your home) If you’ve read my previous post, you already have a beautiful AR floor in your din…

可用于nodejs的SuperAgent(ajax API)
简单示例: import request from superagent;//引用声明 request.post(api).withCredentials()//跨域.end((err, res) > {if (res.ok) {const json JSON.parse(res.text);} else {console.log(获取失败);}}); 1、get 方式 当使用get请求传递查询字符串的时候&…

Java第四次实验
一、实验内容: 结对编程。运行TCP代码,结对进行,一人服务器,一人客户端;利用加解密代码包,编译运行代码,一人加密,一人解密; 集成代码,密后通过TCP发送。 二、…

JS 面向对象编程之原型(prototype)
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 function Person(first, last) {this.first first;this.last last; } Person.prototype.fullName function() {return this.first this.last; } Person.prototype.fullNameReversed function() {…

idea自动捕获_Smilefie:如何通过检测微笑来自动捕获自拍
idea自动捕获by Rishav Agarwal通过里沙夫阿加瓦尔 Smilefie:如何通过检测微笑来自动捕获自拍 (Smilefie: how you can auto-capture selfies by detecting a smile) Ten second takeaway: use Python and OpenCV to create an app that automatically captures a …