Skip to content

Commit

Permalink
Merge pull request fitnessforlife#24 from ArthurZey/add_user_agent_fo…
Browse files Browse the repository at this point in the history
…r_profile_check

Added User-Agent request header to diaryStatusCheck
  • Loading branch information
andrewzey committed Oct 7, 2015
2 parents ae1996a + c4df315 commit cdacd76
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -244,6 +244,7 @@ gulp watch
* 0.5.3 Fix Bug: diaryStatusCheck correctly returns 'invalid user' when hitting 404 page
* 0.5.4 Update dependencies, update tests to use mocha's done() for async tests
* 0.5.5 Add User Agent String to Request Headers to Fix Failing Scraping
* 0.5.6 Add User-Agent String to Request Headers of checking if diary is public

# Known Issues

Expand Down
9 changes: 8 additions & 1 deletion mfp_functions/diaryStatusCheck.js
Expand Up @@ -8,7 +8,14 @@ var diaryStatusCheck = function(username, callback){
//get MyFitnessPal URL (eg. 'http://www.myfitnesspal.com/reports/printable_diary/npmmfp')
var url = helpers.mfpUrl(username);

request(url, function(error, response, body) {
var options = {
url: url,
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'
}
};

request(options, function(error, response, body) {
if (error) throw error;

var $ = cheerio.load(body);
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "mfp",
"version": "0.5.5",
"version": "0.5.6",
"description": "A third-party API for accessing MyFitnessPal diary data",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit cdacd76

Please sign in to comment.