soulpower 3 Posted January 20, 2011 Report Share Posted January 20, 2011 Hey guys... I run a small time article writing service on the side and i'm trying to write a bot that will help me in producing the "report" that I give out after an article is finished. Basically the bot i'm trying to make needs to take a list of keywords, scan the article to see how many times each keyword appears and then give a density percentage for each keyword to put in the report. The thing i'm not sure about is how to have the bot scan the article for each instance of a keyword. So for example the article is 500 words with keywords "dog" and "cat" The bot would scan the article for the keywords and spit out a report with something like "dog - 1% density", "cat - 2% density" I can figure the math out but i'm not sure if i should put the article in a list or how to have the bot scan for each instance of the keywords and count them up. Can you even "search" a list or only webpage? I'm assuming i would be incrementing a variable? Any advice or ideas on this would be greatly appreciated...trying to automate some of these menial tasks. thanx! Quote Link to post Share on other sites
pftg4 102 Posted January 20, 2011 Report Share Posted January 20, 2011 regex can do that for ya Pftg4 Quote Link to post Share on other sites
Gogetta 263 Posted January 20, 2011 Report Share Posted January 20, 2011 Check this thread out. There are a couple of solutions you can try. Quote Link to post Share on other sites
Guerrilla 19 Posted January 20, 2011 Report Share Posted January 20, 2011 Yeah, you can make a regex to do all that for you. There are guys on odesk with loads of regex experience so if you get stuck post a job over there and they will have it done easy for you. Quote Link to post Share on other sites
Guerrilla 19 Posted January 21, 2011 Report Share Posted January 21, 2011 Look at page source of this page: http://www.adamhowitt.com/tools/keyword-density.cfm Looks like he does it with javascript, you could use that as a guide if you wanted to do it yourself. Quote Link to post Share on other sites
soulpower 3 Posted January 21, 2011 Author Report Share Posted January 21, 2011 Check this thread out. There are a couple of solutions you can try. This is great, can't believe i didn't think of that lol. Thanks so much guys for all the suggestions! Quote Link to post Share on other sites
soulpower 3 Posted January 21, 2011 Author Report Share Posted January 21, 2011 actually i've run into my next problem....so now i'm uploading the article to my server and having the bot scrape all the keywords as gogetta showed above. But when i want to use $eval to calculate the density % it doesn't work since this is a plain .txt file that the bot is on. I'm reading that $eval doesn't work if the webpage doesn't support javascript. So i guess my question is, how would I get the page to support javascript? These are all just regular articles in a .txt file that i upload to my server. I'm assuming this is normal or is this a bug? Quote Link to post Share on other sites
pftg4 102 Posted January 21, 2011 Report Share Posted January 21, 2011 try adding this to the page <script type="text/javascript"> i think this should work geurella uploaded in a bot i saw so credit goes to him Pftg4 Quote Link to post Share on other sites
soulpower 3 Posted January 21, 2011 Author Report Share Posted January 21, 2011 try adding this to the page <script type="text/javascript"> i think this should work geurella uploaded in a bot i saw so credit goes to him Pftg4 that worked. I was using .txt files so guess i'll have to convert all articles to php before uploading them. thanks! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.