Find Jobs
Hire Freelancers

Using request and cheerio, create a node.js script to login to portal a keep session alive

$30-250 USD

Completed
Posted almost 6 years ago

$30-250 USD

Paid on delivery
We have a target B2B portal secured by username/password. We want a node.js/express script to login to the portal and keep the session alive as long as possible and then log back in if the remote server unavoidably destroys the session. The expected budget for this project is $50. There are follow-up projects available which will ultimately lead to scraping a lot of data out of the remote site and loading the data into MySql. --------------------------------------------------------------------------- THE FOLLOWING INFORMATION IS FOR CONTEXT ONLY AND IS NOT REQUIRED IN THIS STEP/BID The express application will *eventually* provide a route through which we can HTTP query our server which will in turn request a secured page from the remote server (i.e. scrape the remote host) and return data back to the browser: browser <---> *our node.js/expressApp <---> remote server However, THIS IS NOT REQUIRED IN THIS STEP/BID AND IS ONLY EXPLAINED HERE FOR CONTEXT. --------------------------------------------------------------------------- THE SCRIPT SHOULD TAKE THE FOLLOWING OUTLINE: const request = require('request-promise') const express = require('express') var isLoggedIn = async (r) => { var html = await [login to view URL]('[login to view URL]') return [login to view URL]('Your username is:') // only appears if we have an active session } var login = async (r) => { var html = await [login to view URL]('[login to view URL]', {username: 'superuser', password: 'coolpassword'}) if (!await isLoggedIn(r)) throw "Could not login!" // save the session/cookies to the database await [login to view URL](`update cache set cookies = '${[login to view URL]('[login to view URL]')}'`) } var keepalive = async (r) => { await [login to view URL]('[login to view URL]') // resets the idle timeout on remote server setTimeout(keepalive, randomTimeBetween4And6Minutes) } var connect = async () => { // create a session var jar = [login to view URL]() var r = [login to view URL]({jar: jar}) // restore last session/cookies var cookies = await [login to view URL]('select cookies from cache') for (cookie of cookies) { [login to view URL](cookie), '[login to view URL]') } // login if not already logged in if (!isLoggedIn(r)) login(r) keepalive(r) // keeps the session alive } connect() // Express/HTTP application and routes [login to view URL]('/accountNumber', async (req, res, next) => { var html = await [login to view URL]('[login to view URL]') var accountNumber = [login to view URL](/'Your Account Number: (\d+)/)[1] [login to view URL]({status: 'success', accountNumber: accountNumber}) }) [login to view URL](3000) --------------------------------------------------------------------------- REQUIREMENTS: THE SCRIPT SHOULD DO THE FOLLOWING Reference the above sample script pseudocode and see that the following steps are required: * When the express application starts, load cookies stored in MySql from a previous execution, i.e. var jar = [login to view URL]() var cookies = await [login to view URL]('select cookies from cache') for (cookie of cookies) { [login to view URL](cookie), '[login to view URL]') } * The script should check to see if the session it restored from MySql cookies is still a valid/logged in session. Do this by requesting a page that is generally secured and requires a user to be logged in. Look for indicators in the HTTP response that indicate that the session is logged in or not. If the session is not valid, then try to log in again * If we login, then save the new session/cookies to MySql * Keepalive: Request a page periodically to reset the session timeout counter on the server. * A function to look for an indicator in the HTML of whether our session/cookies are still logged in or not. i.e. [login to view URL]('Your username is:') // only appears if we have an active session --------------------------------------------------------------------------- A WORKING COPY OF ONE OF THESE SCRIPTS IS AVAILABLE HERE: [login to view URL]
Project ID: 17268052

About the project

6 proposals
Remote project
Active 6 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
Highly dedicated, experienced. Have experience creating scraping services, processing thousands of press releases per day.
$50 USD in 3 days
0.0 (0 reviews)
0.0
0.0
6 freelancers are bidding on average $104 USD for this job
User Avatar
Hi, I have used this technique to scrap data from website When i have scrapped data from website where we need login I have good exp there are several factors with each domain with respect to there security and data policies but every time i managed to logged in and scrap data so i think myself good for this task you can find more details about my skills on profile page too thanks
$166 USD in 3 days
5.0 (38 reviews)
6.8
6.8
User Avatar
Hi, I read through the job details extremely carefully and I am absolutely sure that I can do the project very well. Expert in BOTH Backend and Front-end Programming, PHP - OOP, MVC, REST API, HTML/CSS/JAVASCRIPT, Wordpress Theme Integration, Woocommerce/Ecommerce, Magneto,Shopify, Responsive Design, Plugin Development, Adaptive websites, White Hat SEO, Android and IOS App Development. I look forward to a successful working relationship in the future. Kind Regards, Vivek
$50 USD in 2 days
4.9 (8 reviews)
4.8
4.8
User Avatar
I have 6 year experience Freelancer,up work,Fiverr & 99design market place I have seen your project that i can to do easily because I have many experience to Graphic Design,Webdesign,Web Develop & programming .So I could create it for you as soon as that easy but how this have done ,,,,please discuses before start job,,,,
$155 USD in 3 days
5.0 (1 review)
2.7
2.7

About the client

Flag of UNITED STATES
Denver, United States
5.0
25
Payment method verified
Member since Dec 22, 2013

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.