Welcome to WebmasterWorld Guest from 54.158.228.55

Forum Moderators: incrediBILL & martinibuster

Message Too Old, No Replies

Adsense Downloadable Report Auto Retriever

by CFMX6.1 CFHTTP

     
11:24 am on Mar 19, 2004 (gmt 0)

10+ Year Member



I'm using Coldfusion MX 6.1:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>GAS Report</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<!--- Input username below --->

<cfset strYourEmailAddress="YOUEmailAddress">

<!--- Input password below --->

<cfset strYourPassword="YourPassWord">

<cfset strTimePeriod="thismonth">
<!--- Select one or input one you want to retrieve (by URL.strTimePeriod or Form.strTimePeriod)
<cfset strTimePeriod="alltime">
<cfset strTimePeriod="today">
<cfset strTimePeriod="yesterday">
<cfset strTimePeriod="last7days">
<cfset strTimePeriod="lastmonth">
--->
<cfset strGasURLstart="https://www.google.com/adsense/reports-aggregate?timeperiod=simple&timeperiod.simpletimeperiod=">
<cfset strGasURLend="&reportType=property&groupByPref=date&null=Display+Report&csv=true">
<!--- The URL to be retrieved --->
<cfset strGasURL= strGasURLstart & strTimePeriod & strGasURLend>
<!--- Your userAgent --->
<cfset strUserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)">
<cfhttp
url = "https://www.google.com/adsense/login.do"
method = "post"
userAgent = "#strUserAgent#"
>
<cfhttpparam type="FORMFIELD" name="destination" value="">
<cfhttpparam type="FORMFIELD" name="username" value="#strYourEmailAddress#">
<cfhttpparam type="FORMFIELD" name="password" value="#strYourPassword#">
<cfhttpparam type="FORMFIELD" name="null" value="Login">
</cfhttp>
<cfset pos1=find("?s=","#cfhttp.fileContent#",1)>
<cfif pos1>
<cfset pos2=find("&","#cfhttp.fileContent#",pos1)>
<cfset strS=mid("#cfhttp.fileContent#",pos1+3,pos2-pos1-3)>
<cfif len(strS) EQ 11> <!--- the URL session "s" of GAS, I guess --->
<cfoutput>#strS#</cfoutput>
<cfset strGasURL= strGasURLstart & strTimePeriod & strGasURLend & "&s=#strS#">
<cfhttp url = "#strGasURL#" method = "get" userAgent = "#strUserAgent#" name = "qryGASreport"> </cfhttp>
<cfif isdefined("qryGASreport")>
<cfoutput>
<cfdump var="#qryGASreport#">
</cfoutput>
</cfif>
</cfif>
</cfif>
</body>
</html>

=============================
Feedback welcome!

[edited by: zhenghua at 2:21 pm (utc) on Mar. 19, 2004]

11:27 am on Mar 19, 2004 (gmt 0)

10+ Year Member



<add>Actually 2 cfhttp.
(1) First to log onto the GAS by POST;
(2) Then got the value of "s", it is a tricky URL value of GAS, and CFHTTP by GET again.</add>
12:20 pm on Mar 19, 2004 (gmt 0)

10+ Year Member



Hi zhenghua

Nice idea. Unfortunately I get an error:

Invalid CFML construct found on line 51 at column 12.
ColdFusion was looking at the following text:
=

The CFML compiler was processing:

a cfhttpurl tag beginning on line 51, column 2.
a cfhttpurl tag beginning on line 51, column 2.
a cfhttpurl tag beginning on line 51, column 2.


The error occurred in D:\root\pub\ads.cfm: line 51

49 : <cfoutput>#strS#</cfoutput>
50 : <cfset strGasURL= strGasURLstart & strTimePeriod & strGasURLend & "&s=#strS#">
51 : <cfhttpurl = "#strGasURL#" method = "get" userAgent = "#strUserAgent#" name = "qryGASreport"> </cfhttp>
52 : <cfif isdefined("qryGASreport")>
53 : <cfoutput>

Not sure I understand your second post. Are you looking for ideas to get this working or does it work for you already?

12:43 pm on Mar 19, 2004 (gmt 0)

10+ Year Member



Hi Stretch,

1) It works on my CFMX6.1 server,
2) I think maybe you can debug after Line 49 : <cfoutput>#strS#</cfoutput> .
<!---
<cfset strGasURL= strGasURLstart & strTimePeriod & strGasURLend & "&s=#strS#">
<cfhttpurl = "#strGasURL#" method = "get" userAgent = "#strUserAgent#" name = "qryGASreport"> </cfhttp>
<cfif isdefined("qryGASreport")>
<cfoutput>
<cfdump var="#qryGASreport#">
</cfoutput>

--->
Just to see if the fist CFHTTP got the value of "s". If Not, maybe there is a network problem, in fact, the length of "s" is 11.

12:48 pm on Mar 19, 2004 (gmt 0)

10+ Year Member



Or, change line 48 to <cfif len(strS) EQ 11> ,
because as I see so far, the session value "s" always has 11 length.
12:51 pm on Mar 19, 2004 (gmt 0)

10+ Year Member



(1)In fact, it works, and I add this page to my Desktop Item as an Active Desktop, haha.
(2) You can also use cfschedule to get the new results every 1 hour (less than 30 mins will be banned, I've heard that before), then trigger a cfmail to you if results updated.
(3) Use coldfusion/javascript to draw diagram, I'm working on it now.
(4) Anything else you can imagine...
1:07 pm on Mar 19, 2004 (gmt 0)

10+ Year Member



Stretch, it looks like you are missing a space between the <cfhttp AND url part on line 51!

Line 51 should read like this


<cfhttp url = "#strGasURL#" method = "get" userAgent = "#strUserAgent#" name = "qryGASreport"> </cfhttp>

note the space AFTER <cfhttp and BEFORE the url =

I'm at the moment not behind my PC/Server so I can not test it!

Noel

1:20 pm on Mar 19, 2004 (gmt 0)

10+ Year Member



Hypothetical Output
(No real stuff is revealed per Google TOS)

tKQ_LX4AqS9

Date Page impressions Clicks Clickthrough rate Your earnings
3/1/2004 17070 809 4.74% $412.59
3/2/2004 17009 506 2.97% $227.70
3/3/2004 20107 503 2.50% $352.10
3/4/2004 20404 608 2.98% $729.60
3/5/2004 20104 502 2.50% $160.64
3/6/2004 10206 601 5.89% $264.44
3/7/2004 13004 450 3.46% $247.50
3/8/2004 10409 801 7.70% $312.39
3/9/2004 10500 902 8.59% $405.90
3/10/2004 10906 689 6.32% $509.86
3/11/2004 20503 547 2.67% $224.27
3/12/2004 10201 214 2.10% $186.18
3/13/2004 10407 200 1.92% $112.00
3/14/2004 40908 1678 4.10% $369.16
3/15/2004 20307 698 3.44% $328.06
3/16/2004 30605 914 2.99% $594.10
3/17/2004 20306 1056 5.20% $686.40
3/18/2004 40356 2047 5.07% $921.15
3/19/2004 401 20 4.99% $17.80

Totals 343713 13745 4.2% $7061.84


(No real stuff is revealed per TOS)
Hypothetical Output
1:43 pm on Mar 19, 2004 (gmt 0)

10+ Year Member



Yeah, it was the missing space that caused the error. Thanks for that.

I'm now not getting an error, but I'm only getting the 11 character tracking code.

If I remove the <cfif isdefined("qryGASreport")> and just dump qryGASreport it always returns an undefined error.

I'm going to keep playing - this is a great idea so hopefully I'll get it working.

2:11 pm on Mar 19, 2004 (gmt 0)

10+ Year Member



Hi Stretch,
"qryGASreport" is a query, cfdump can display it, if you're using CFMX 6.1, I'm not sure if previous version of coldfusion support or not, though I've been using Coldfusion for over 6 years, ha-ha.

Try this, if you cannot cfdump.


<cfhttp url="#strGasURL#" method="get" userAgent="#strUserAgent#" name="ryGASreport"></cfhttp>
<cfoutput><pre>#cfhttp.fileContent#</pre></cfoutput>
2:51 pm on Mar 19, 2004 (gmt 0)

10+ Year Member



Thanks zhenghua.

<cfoutput><pre>#cfhttp.fileContent#</pre></cfoutput> works :-)

"qryGASreport" is a query, cfdump can display it, if you're using CFMX 6.1

I understand the query & dump stuff and I'm using MX 6.1. For some reason though it appears that the 'cfhttp' wasn't being assigned the query name like it was being told to. Because of this "qryGASreport" was always undefined. Weird. Anyway, outputting the #cfhttp.fileContent# works so thank you!

This is a great piece of code and I'd be interested to see what else you manage to do with it.

Thanks again.

Stretch

3:09 pm on Mar 19, 2004 (gmt 0)

10+ Year Member




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>AdSense Downloadable Report Auto Retriever (V1.0.2b)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
.styf1 {
font-size: 12px;
color: 666666;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
-->
</style>
</head>
<body>
<!--- Input username below --->
<cfset strYourEmailAddress="REPLACE WITH YOUR EMAIL ADDRESS">
<!--- Input password below --->
<cfset strYourPassword="REPLACE WITH YOUR Password">
<!---
Select one or input one you want to retrieve (by URL.strTimePeriod or Form.strTimePeriod)
<cfset strTimePeriod="alltime">
<cfset strTimePeriod="today">
<cfset strTimePeriod="yesterday">
<cfset strTimePeriod="last7days">
<cfset strTimePeriod="lastmonth">
--->

<cfset strTimePeriod="thismonth">

<cfset strGasURLstart="https://www.google.com/adsense/reports-aggregate?timeperiod=simple&timeperiod.simpletimeperiod=">
<cfset strGasURLend="&reportType=property&groupByPref=date&null=Display+Report&csv=true">
<!--- The URL to be retrieved --->
<cfset strGasURL= strGasURLstart & strTimePeriod & strGasURLend>
<!--- Your userAgent --->
<cfset strUserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)">
<cfhttp
url = "https://www.google.com/adsense/login.do"
method = "post"
userAgent = "#strUserAgent#"
>
<cfhttpparam type="FORMFIELD" name="destination" value="">
<cfhttpparam type="FORMFIELD" name="username" value="#strYourEmailAddress#">
<cfhttpparam type="FORMFIELD" name="password" value="#strYourPassword#">
<cfhttpparam type="FORMFIELD" name="null" value="Login">
</cfhttp>
<cfset pos1=find("?s=","#cfhttp.fileContent#",1)>
<cfif pos1>
<cfset pos2=find("&","#cfhttp.fileContent#",pos1)>
<cfset strS=mid("#cfhttp.fileContent#",pos1+3,pos2-pos1-3)>
<cfif len(strS) EQ 11>

<cfset strGasURL= strGasURLstart & strTimePeriod & strGasURLend & "&s=#strS#">
<cfoutput>URL:#strGasURL#</cfoutput>
<cfhttp url="#strGasURL#" method="get" userAgent="#strUserAgent#" name="ryGASreport"></cfhttp>
<cfoutput><pre>#cfhttp.fileContent#</pre></cfoutput>
<cfelse>
No data available. Try at least 1 hour Later....
</cfif>
<cfelse>
No data available. Try at least 1 hour Later....
</cfif>

<p>Updated Mar 19, 2004<strong> V1.0.2b</strong><br/>
<br/>
<span class="styf1">Google<sup>TM</sup> is a trademark of Google Inc. Google AdSense is for web publishers who want to make more revenue from advertising on their site while maintaining editorial quality. AdSense delivers text-based Google AdWords ads that are relevant to what your readers see on your pages and Google pays you. <a href="https://www.google.com/adsense/faq#start1" target="_blank">What is Google AdSense? </a></span> </p>
</body>
</html>
</body>
</html>

8:35 pm on Mar 19, 2004 (gmt 0)

10+ Year Member



is ASP capable of doing this?
9:12 pm on Mar 19, 2004 (gmt 0)

10+ Year Member



Ok, here is my (possibly poor) approximation of an ASP version...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>AdSense Downloadable Report Auto Retriever (V1.0.2b)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
.styf1 {
font-size: 12px;
color: #666;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
-->
</style>
</head>
<body>
<%
'Input username below
strYourEmailAddress="REPLACE WITH YOUR EMAIL ADDRESS"
'Input password below
strYourPassword="REPLACE WITH YOUR Password"

'Select one or input one you want to retrieve (by URL.strTimePeriod or Form.strTimePeriod)
' strTimePeriod = "alltime"
' strTimePeriod = "today"
' strTimePeriod = "yesterday"
' strTimePeriod = "last7days"
' strTimePeriod = "lastmonth"
strTimePeriod = "thismonth"

strGasURLstart = "https://www.google.com/adsense/reports-aggregate?timeperiod=simple&timeperiod.simpletimeperiod="
strGasURLend = "&reportType=property&groupByPref=date&null=Display+Report&csv=true"
'The URL to be retrieved
strGasURL = strGasURLstart & strTimePeriod & strGasURLend
'Your userAgent
strUserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
%>
<form action="https://www.google.com/adsense/login.do" method="post" userAgent="<%= strUserAgent %>">
<input type="hidden" name="destination" value="">
<input type="hidden" name="username" value="<%= strYourEmailAddress %>">
<input type="hidden" name="password" value="<%= strYourPassword %>">
<input type="hidden" name="null" value="Login">
</form>
<%
pos1 = instr(cfhttp.fileContent,"?s=",1)
if pos1 then
pos2 = instr(cfhttp.fileContent,"&",pos1)
strS = mid(cfhttp.fileContent,(pos1+3),(pos2-pos1-3))
if len(strS) = 11 then
strGasURL = strGasURLstart & strTimePeriod & strGasURLend & "&s=" & strS
response.write "URL:" & strGasURL
%>
<form action="<%= strGasURL %>" method="get" userAgent="<%= strUserAgent %>" name="<%= ryGASreport %>" />
<%
response.write "<pre>" & cfhttp.fileContent & "</pre>"
else
response.write "No data available. Try at least 1 hour Later...".
end if
else
response.write "No data available. Try at least 1 hour Later...."
end if
%>
<p>Updated Mar 19, 2004<strong> V1.0.2b.asp</strong><br/>
<br/>
<span class="styf1">Google<sup>TM</sup> is a trademark of Google Inc.
Google AdSense is for web publishers who want to make more revenue from
advertising on their site while maintaining editorial quality. AdSense
delivers text-based Google AdWords ads that are relevant to what your
readers see on your pages and Google pays you.
<a href="https://www.google.com/adsense/faq#start1" target="_blank">What
is Google AdSense?</a></span></p>
</body>
</html>
</body>
</html>


I suspect it won't work as is...
10:42 pm on Mar 19, 2004 (gmt 0)

10+ Year Member



Okay, I got a sample url for you all with diagram at:

HTTP:\\myWebsiteName/gas/

(Per TOS of this forum, I cannot tell "myWebsiteName", but you REALLY can check my profile...to find "myWebsiteName" ha-ha)

Feedback welcome, please don't hack my webiste, thanks!

11:08 pm on Mar 19, 2004 (gmt 0)

10+ Year Member



Yes.. and you really think I'm going to enter my login data (-:

Noel

11:17 pm on Mar 19, 2004 (gmt 0)

10+ Year Member



I thought that too
11:19 pm on Mar 19, 2004 (gmt 0)

10+ Year Member



Hi Noel,

I know some of you worry about it, but as my website is 6-year-old, I'm sure in fact I don't want to steal other guys' information, just to show how to use diagram without database. The bottom line is you can always change password after you've tried that. In addition, if you know what kinda business I am doing, you have to trust me, ha-ha.

Have fun!

11:23 pm on Mar 19, 2004 (gmt 0)

10+ Year Member



I have a perl script that I used to download old style reports and that I modified yesterday to download new reports as well. I guess I can open-source it and post it to my web site, but then I can't post links here and I was told I can't even reply to stickies. So, I'll leave it up to interested parties (if there are any) to figure that out :)
11:31 pm on Mar 19, 2004 (gmt 0)

10+ Year Member



zhenghua, I'm still not going to enter my data in there :-)

Why not make a screen shot of a report (with the sensitive data removed or changed if needed) and put it on that page?

Noel

11:43 pm on Mar 19, 2004 (gmt 0)

10+ Year Member



Hi Noel,

Thanks for your nice suggestion, but so far I don't want to make it a commerce service, and do it as a hobby, just for fun. Okay, I add a ugly enough screen snapshot there.

As a serious businessman, I promise not to steal/peek/collect/store your information. that's that.

Zhenghua

2:55 am on Mar 20, 2004 (gmt 0)

10+ Year Member



As a serious business man, I don't think it's a good idea to ever rely on an Internet promise. No offense intended zenghua, but if someone doesn't know who the person they're supposed to trust is, it would be foolish to trust them with important confidential information.
3:23 am on Mar 20, 2004 (gmt 0)

10+ Year Member



Hi billegal,

Ha-ha, I even don't expect any skeptic go there, who will pay for the traffic of my website?

Good to see your input, and have a GREAT weekend!

Zhenghua

7:00 am on Mar 20, 2004 (gmt 0)

10+ Year Member



zhenghua, as a businessman, would YOU reveal your Adsense username/password combo on a third-party site?
6:08 pm on Mar 20, 2004 (gmt 0)

10+ Year Member



Hi Stretch,

See, I know some of them don't trust others, that's okay, and my business solely based on trust, I completely understand their concerns.

Since I'm not going to sell it or persuade others to try it, I feel comfortable and willing to agree to disagree, where each side acknowledges that the
others has different points of view and that's the law of natural.

I'm going to continue my work and don't have time to waste on resolving impossible arguments.

Thanks,

Zhenghua

6:16 pm on Mar 20, 2004 (gmt 0)

WebmasterWorld Senior Member jomaxx is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Not that you would, but you could change the name and address that the checks go to. Yikes.
6:22 pm on Mar 20, 2004 (gmt 0)

10+ Year Member



Not that you would, but you could change the name and address that the checks go to. Yikes

Per GAS TOS, when change payee's name, you need to write email to request. And it's a criminal, don't you think so?

9:21 pm on Mar 20, 2004 (gmt 0)

10+ Year Member



you have to trust me, ha-ha.

As a serious businessman, I promise not to steal/peek/collect/store your information.

OK zhenghua, enough is enough.

Adsense publishers can check their stats easily when they login to their account: [google.com...]

So, why do we need your "service"?
Why are you encouraging Adsense publishers to reveal their Adsense username/password on your site?

11:30 pm on Mar 20, 2004 (gmt 0)

10+ Year Member



Hi tombola,

In fact, at marketplace there are at least 10 or more services for Adsense Report analysis, most of them are free.

I never say you NEED to try mine or others, you can always use your own analysis scripts/tools at your own website(s), you can also log in [google.com...]

My purpose is only open source a possible way to use the report, not persuade others to try this at my own website, as I mentioned before, I do care about the traffic expense.

I never lobby anyone to try this, my only intention is to show kindness to you all, especially who interested in this scripts, to show them how to use Coldfusion to download this report and make it a more human-readable diagram.

Thanks for your time,

Zhenghua

11:48 pm on Mar 20, 2004 (gmt 0)

10+ Year Member



Before you reply, please let me do some review of this thread by timeline :-)

1) I posted a cfml script to show how to download the report.
2) Stretch replied me to discuss a bug;
3) Noel corrected the problem;
4) Stretch worked well about this script;
5) I said I could make some improvement, then told the location ...
6) Noel said people may not want to try it at my website;
7) In fact, I just show it to Stretch, because he/she encouraged me to do more, and I did it;
8) Stretch did not reply me, but some replied with same theme "we don't want to try".
9) The thing is I do NOT want you to try.

This 42 message thread spans 2 pages: 42
 

Featured Threads

Hot Threads This Week

Hot Threads This Month