iTunes Connect网页抓取,Powershell,无法登录-什么是“;AuxValue”;?
我一直在尝试这个项目,因为去年年底,我与这个问题困了很长一段时间。我真的需要帮忙 问题是我想我没有登录 我的代码是iTunes Connect网页抓取,Powershell,无法登录-什么是“;AuxValue”;?,powershell,web-scraping,app-store-connect,Powershell,Web Scraping,App Store Connect,我一直在尝试这个项目,因为去年年底,我与这个问题困了很长一段时间。我真的需要帮忙 问题是我想我没有登录 我的代码是 $loginBase = "https://itunesconnect.apple.com"; $loginUrl = $loginBase + "/WebObjects/iTunesConnect.woa/wo"; $r = Invoke-WebRequest $loginUrl -SessionVariable ws; $ws $form = $r.Forms[0
$loginBase = "https://itunesconnect.apple.com";
$loginUrl = $loginBase + "/WebObjects/iTunesConnect.woa/wo";
$r = Invoke-WebRequest $loginUrl -SessionVariable ws;
$ws
$form = $r.Forms[0];
$form| Format-List
$form.fields
$form.Fields["accountname"] = "username";
$form.Fields["accountpassword"] = "password";
$form.Fields["theAuxValue"] = "";
$form.fields
$r = Invoke-WebRequest -uri ($loginBase + $form.Action) -WebSession $ws -Method $form.Method -Body $form.Fields;
$r.StatusCode
$r.StatusDescription
$r.content
$jsonSummaryUrl = "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wo/ra/apps/manageyourapps/summary";
$response = Invoke-WebRequest $jsonSummaryUrl -WebSession $ws;
$response.StatusCode
$response.StatusDescription
$response.content
输出是
Headers : {}
Cookies : System.Net.CookieContainer
UseDefaultCredentials : False
Credentials :
Certificates :
UserAgent : Mozilla/5.0 (Windows NT; Windows NT 6.1; en-US) WindowsPowerShell/3.0
Proxy :
MaximumRedirection : -1
Id : appleConnectForm
Method : post
Action : /WebObjects/iTunesConnect.woa/wo/0.0.1.17.3.13.3.2.1.1.3.1.1
Fields : {[accountname, ], [accountpassword, ], [theAuxValue, ], [inframe, 0]}
Key Value
--- -----
accountname
accountpassword
theAuxValue
inframe 0
accountname username
accountpassword password
theAuxValue
inframe 0
200
OK
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>iTunes Connect</title>
<meta name="apple-itunes-app" content="app-id=376771144" />
<link href="/c/1450307132/dcfcd616d3232d45ba91c598fceecb45/itc/css/compiled/global_header_footer.css" media="screen, projection" rel="stylesheet" type="text/css" />
<link href="/c/1450307132/b5be5ab894bfb31372e451d4ef495483/itc/css/compiled/interstitial.css" media="screen, projection" rel="stylesheet" type="text/css" />
<script src="/c/1450307132/32843bda7b7abb11a2ca7d7a1088c6f3/itc/js/lib/jquery.min.js"></script>
</head>
<body class="signin"><div id="pageWrapper">
<div id="header">
<div id="logo">
<span>iTunes Connect</span>
</div>
<a href="http://www.apple.com/itunes/sellcontent/" class="hero-link hl--secondary">Learn More</a>
<div id="resources-help" class="dropdownmenu">
<a href="" class="icon-help menuopener"></a>
<ul role="menu" id="help-menu">
<li class="sectionBreak"><a href="https://itunesconnect.apple.com/help/">All Resources and Help</a></li>
<li><a href="https://itunesconnect.apple.com/help/news/">News</a></li>
<li><a href="https://itunesconnect.apple.com/help/guides/">Guides</a></li>
<li><a href="https://itunesconnect.apple.com/help/videos/">Videos</a></li>
<li class="sectionBreak"><a href="https://itunesconnect.apple.com/help/faq/">FAQ</a></li>
<li><a href="https://www.apple.com/itunes/go/itunesconnect/contactus">Contact Us</a></li>
</ul>
</div>
</div>
<script>
window.l10login = {
signIn: 'Sign In',
appleID: 'Apple ID',
password: 'Password',
signedOut: 'You have successfully signed out.',
sessionExpired: 'Your session has expired.',
}
</script>
<div id="wrapper" class="itc-auth">
<div class="box-container">
<div class="box sign-in">
<h2 class="itc-signin-header">
Sign In to</br> iTunes Connect
</h2>
<script>
function dsfocus(){ document.appleConnectForm.theAccountName.focus(); }
</script>
<div id="ds_container">
<form name="appleConnectForm" method="post" action="/WebObjects/iTunesConnect.woa/wo/1.0.1.17.3.13.3.2.1.1.3.1.1">
<font face="Lucida Grande, Geneva, Verdana, Arial, Helvetica, sans-serif" class="L12" />
<font size=2>
<span class="dstext"></span>
</font>
</font /><br><br>
<table border='0' cellpadding='0' cellspacing='0'>
<tr valign='top'>
<td><img alt="Alert" width="16" height="11" src="/AppleConnect/US-EN/iconsmallalert.gif" />
<font face="Geneva, Verdana, Arial, Helvetica, sans-serif" size=1 class="G10" /><font color="#ff0000" size=1>
<span class="dserror">Your Apple ID or password was entered incorrectly.</span>
</font></font />
<br><br>
</td>
<td width='11'></td>
</tr>
</table>
<table cellpadding=0 cellspacing=0 border=0 width=273>
<tr valign=top>
<td align=left><font size=2><font face="Geneva, Verdana, Arial, Helvetica, sans-serif" size=1 class="G10" />
<label for="accountname"><span class="dslabel">Apple ID</span></label>
<font color="#ff1102"></font></font /><br>
<font size='2'><input size="30" autocapitalize="off" autocorrect="off" maxlength="128" id="accountname" type="text" name="theAccountName" /></font></font>
</td>
</tr>
<tr><td><img alt="" width="273" height="5" src="/AppleConnect/US-EN/spacer.gif" /></td></tr>
<tr><td><img alt="" width="273" height="5" src="/AppleConnect/US-EN/spacer.gif" /></td></tr>
<tr>
<td align='left'>
<font face="Geneva, Verdana, Arial, Helvetica, sans-serif" size=1 class="G10" />
<label for="accountpassword"><span class="dslabel">Password</span></label>
</font />
<br>
<input size="30" autocapitalize="off" oncut="return false ;" oncopy="return false ;" autocorrect="off" id="accountpassword" type="password" name="theAccountPW" /><input border="0" width="0" height="0" type="image" name=
"1.Continue" src="/AppleConnect/US-EN/spacer.gif" />
</td>
</tr>
<tr><td><img alt="" width="273" height="5" src="/AppleConnect/US-EN/spacer.gif" /></td></tr>
<tr><td><img alt="" width="273" height="5" src="/AppleConnect/US-EN/spacer.gif" /></td></tr>
<tr>
<td>
<table cellspacing='0' border='0' width='273' cellpadding='0'>
<tr align='left'>
<td align='left' width='170'>
<font size='1'>
<span class="dstext">
<input border="0" alt="Did you forget your password?" type="image" name="1.Forgot" src="/AppleConnect/US-EN/labelconnect/iforgot-link.png" />
</span>
</font>
</td>
<td width='15'><img alt="" width="15" height="5" src="/AppleConnect/US-EN/spacer.gif" /></td>
<td align='left' width='88'><input border="0" alt="Sign In" type="image" name="1.Continue" src="/AppleConnect/US-EN/labelconnect/btn-sign-in.png" /></td>
</tr>
</table>
</td>
</tr>
</table>
<input type="hidden" name="theAuxValue" />
<input id="inframe" type="hidden" value="0" name="inframe" />
</form>
<script>
var isInIframe = (self != top);
var elem = document.getElementById("inframe");
if (isInIframe==false)
elem.value="0";
else
elem.value="1";
</script>
</div>
<input style='display: none' id="ac_invites" type="text" name="0.1.17.3.13.5" />
<div id="msg-container">
</div>
</div>
<div class="box-signin-shadow"></div>
</div>
</div>
<div class="modal-container" style="display: none">
<form method="post" class="dsform" action="" id="expiredPasswordFormClone">
<div id="modal" class="modal-dialog">
<div class="modal-dialog-content">
<h1>Password Expired</h1>
<p style="margin-top: 10px">Your password has expired. To change it, go to <a href="http://appleid.apple.com">appleid.apple.com</a>.</p>
</div>
<div class="modal-buttons">
<div class="right-buttons">
<button class="primary" onclick="cancelExpiredForm()">Close</button>
</div>
</div>
</div>
</form>
</div>
<script>
(function() {
var body = document.getElementsByTagName('body')[0];
body.setAttribute('class', 'signin');
})();
</script>
<script>
$(function() {
// Add Learn More link to header.
// var learnMoreText = 'Learn More',
// learnMoreLink = '<a href="http://www.apple.com/itunes/sellcontent/" class="hero-link hl--secondary">'+learnMoreText+'</a>';
//$('#header').append(learnMoreLink);
// Add iForgot link to footer
var iForgotLink = "<li><a href='https://iforgot.apple.com/password'>Forgot your Apple ID or password?</a></li>";
$(iForgotLink).insertBefore('#footer li:first-child')
// If we receive "Expired Password" interface, display it as a modal window
var expForm = $('form[name="appleConnectExpiredPasswordForm"]');
if ( expForm.length > 0 ) {
var errors = expForm.find('span.dserror');
var action = expForm.attr('action');
if (errors.length > 0) {
errors.each( function() {
$('#ds_error_list').append('<li><div class="errormessages">'+$(this).text()+'</div></li>' );
$('#ds_error_list').show();
})
} else {
$('#ds_error_list').hide();
}
var newForm = expForm.clone();
$('.box.sign-in').hide();
$('#expiredPasswordFormClone').attr('name','appleConnectExpiredPasswordForm').attr('action',action);
$('.modal-container').show();
expForm.remove();
}
});
window.submitExpiredForm = function() {
var form = document.appleConnectExpiredPasswordForm || document.getElementById('expiredPasswordFormClone') || document.forms[0];
if (typeof form.submit === 'function') {
form.submit();
}
return form;
}
var cancelExpiredForm = function() {
document.cookie="wosid=''; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/";
/* $('.box.sign-in').show();
$('.modal-container').hide();*/
}
</script>
</div>
<div id="footer" class="footer not-global-style">
<a href="http://www.apple.com" class="no-text ico-apple">Apple.com</a>
<div class="right">
<p>
Copyright © 2016 Apple Inc. All rights reserved.
</p>
<ul>
<li>
<a href="http://www.apple.com/legal/privacy">Privacy Policy</a>
</li>
</ul>
</div>
</div>
<!-- <script src="/c/1450307132/c73408c8ecc03f63c15cd8ff11536d1d/itc/js/cleanwrapper.js"></script> -->
<script src="/c/1450307132/e15e739d0caf0edc86dd4889060ae763/itc/js/signin.js"></script>
</body>
</HTML>
<script language="JavaScript" type="text/javascript" src="/c/1450307132/ef79b24de870765686c7bce9b178a66a/itc/js/omniture/library.js"></script>
<script language="JavaScript" type="text/javascript"><!--
/* You may give each page an identifying name, server, and channel on
the next lines. */
s.pageName="iTC Sign In Redesign"
s.channel="Sign In"
s.hier5="appleitmsitcdev"
/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
var s_code=s.t();if(s_code)document.write(s_code)//--></script>
<script language="JavaScript" type="text/javascript"><!--
if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-')
//--></script><noscript><img src="http://metrics.apple.com/b/ss/appleitmsna/1/H.24--NS/0"
height="1" width="1" border="0" alt="" /></noscript>
200
OK
标题:{}
Cookies:System.Net.CookieContainer
UseDefaultCredentials:False
资格证书:
证书:
用户代理:Mozilla/5.0(Windows NT;Windows NT 6.1;en-US)Windows PowerShell/3.0
代理:
最大重定向:-1
Id:appleConnectForm
方法:邮寄
操作:/WebObjects/iTunesConnect.woa/wo/0.0.1.17.3.13.3.2.1.1.3.1.1
字段:{[accountname],[accountpassword],[theAuxValue],[inframe,0]}
关键值
--- -----
帐户名
帐户密码
超额价值
下部0
帐户名用户名
帐户密码
超额价值
下部0
200
好啊
iTunes连接
iTunes连接
window.l10登录={
签到:'签到',
苹果ID:'苹果ID',
密码:“password”,
signedOut:“您已成功注销。”,
sessionExpired:“您的会话已过期。”,
}
登录到iTunes Connect
函数dsfocus(){document.appleConnectForm.theAccountName.focus();}
您的Apple ID或密码输入不正确。
苹果ID
密码
class itunesConnectApi
{
private $_baseURL = "https://itunesconnect.apple.com/";
private $_itunesUserLoginKey = "accountName";
private $_itunesUserLoginPass = "password";
private $_itunesUserRemember = "rememberMe";
private $_currentCookies = null;
private $_cookiesToUse = array();
private $_loginURL = "https://idmsa.apple.com/appleauth/auth/signin";
public function login($user,$password) {
//Execute the cURL
$response = $this->executeCurl($this->_loginURL,false,"POST",array( $this->_itunesUserLoginKey=>$user,
$this->_itunesUserLoginPass=>$password,
$this->_itunesUserRemember=>true));
//Do we have the myacinfo cookie ?
if(isset($this->_currentCookies["myacinfo"])){
//Add it to current cookies we should use
$this->_cookiesToUse["myacinfo"] = $this->_currentCookies["myacinfo"];
return true;
}
return false;
}
public function loginOverHead()
{
$url = "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wa/route?noext";
$response = $this->executeCurl($url,false,"GET");
if(isset($this->_currentCookies["wosid"]) && isset($this->_currentCookies["woinst"])){
$this->_cookiesToUse["wosid"] = $this->_currentCookies["wosid"];
$this->_cookiesToUse["woinst"] = $this->_currentCookies["woinst"];
return $this->getItcTx();
}
return false;
}
public function getItcTx()
{
$url = "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa";
$response = $this->executeCurl($url,false,"GET");
if(isset($this->_currentCookies["itctx"])){
$this->_cookiesToUse["itctx"] = $this->_currentCookies["itctx"];
return true;
}
return false;
}
public function fetchData($url)
{
$data = $this->executeCurl($url,false);
header('Content-Type: application/json; charset=utf-8');
print_r($data["data"]);
die;
}
private function executeCurl($url,$follow_redirect = true,$httpMethod = "GET",$data = array())
{
$fields_string = "";
if(count($data) > 0){
foreach($data as $key=>$value) {
$fields_string .= $key.'='.$value.'&';
}
$fields_string = rtrim($fields_string, '&');
if($httpMethod == "GET"){
$url = $url."?".$fields_string;
}
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_VERBOSE, '1');
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json')
);
if($httpMethod == "POST" && count($data) > 0){
curl_setopt($curl,CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl,CURLOPT_POST, count($data));
curl_setopt($curl,CURLOPT_POSTFIELDS, json_encode($data));
}
if($this->_currentCookies != null){
if(isset($this->_currentCookies["wosid"]) && isset($this->_currentCookies["woinst"]))
{
curl_setopt($curl, CURLOPT_COOKIESESSION, true);
$cookie = "";
foreach($this->_cookiesToUse as $key=>$val){
$cookie.= $key."=".$val.";";
}
curl_setopt($curl, CURLOPT_COOKIE, $cookie);
}
else if(isset($this->_currentCookies["myacinfo"])){
curl_setopt($curl, CURLOPT_COOKIESESSION, true);
$cookie = "";
foreach($this->_currentCookies as $key=>$val){
$cookie.= $key."=".$val.";";
}
curl_setopt($curl, CURLOPT_COOKIE, $cookie);
}
}
$return = curl_exec($curl);
$info = curl_getinfo($curl);
$code = $info["http_code"];
curl_close($curl);
$this->extractCookies($return);
if($code == 302 ){
if($follow_redirect){
return $this->executeCurl($info["redirect_url"]);
}else{
if($this->_currentCookies == null){
$this->extractCookies($return);
}
return true;
}
}
$header_size= $info["header_size"];
$header = substr($return, 0, $header_size);
$body = substr($return, $header_size);
return array("info"=>$info,"data"=>$body);
}
private function extractCookies($result)
{
preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $result, $matches);
$cookies = array();
foreach($matches[1] as $item) {
parse_str($item, $cookie);
$cookies = array_merge($cookies, $cookie);
}
$this->_currentCookies = $cookies;
}
}
define('ITUNES_CONNECT_LIST_APPS','https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/manageyourapps/summary/v2');
$api = new itunesConnectApi();
if($l = $api->login("myappleid@login.fr","myextremepassword")){
if($api->loginOverHead()){
$allAppData = $api->fetchData(ITUNES_CONNECT_LIST_APPS);
print_r("<pre>");
print_r($allAppData);
print_r("</pre>");
}else{
die("unable to fetch additionnal cookies");
}
}else{
die("unable to login");
}
die;