forked from cveira/social-media-scripting-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPSBrowsingModule.ps1
More file actions
93 lines (72 loc) · 3.1 KB
/
Copy pathPSBrowsingModule.ps1
File metadata and controls
93 lines (72 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<#
-------------------------------------------------------------------------------
Name: Social Media Scripting Framework
Module: Web browsing
Version: 0.2 BETA
Date: 2013/02/03
Author: Carlos Veira Lorenzo
e-mail: cveira [at] thinkinbig [dot] org
blog: thinkinbig.org
twitter: @cveira
facebook: www.facebook.com/cveira
Google+: gplus.to/cveira
LinkedIn: es.linkedin.com/in/cveira/
-------------------------------------------------------------------------------
Support:
http://thinkinbig.org/oms/
Forums & Communities:
facebook.com/ThinkInBig
gplus.to/ThinkInBig
http://bit.ly/SMSF-Forum
-------------------------------------------------------------------------------
Code Mirror Sites:
https://smsf.codeplex.com/
https://github.com/cveira/social-media-scripting-framework
https://code.google.com/p/social-media-scripting-framework/
http://sourceforge.net/projects/smsf/
-------------------------------------------------------------------------------
Social Media Scripting Framework.
Copyright (C) 2013 Carlos Veira Lorenzo.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-------------------------------------------------------------------------------
#>
function Get-PageSourceCode( [string] $QueryURL ) {
# Get-PageSourceCode https://twitter.com/cveira/status/275929500183830529
Add-Type -Assembly System.Web
$WebClient = New-Object System.Net.WebClient
$WebClient.Encoding = [System.Text.Encoding]::UTF8
$PageSourceCode = $WebClient.DownloadString($QueryURL)
$PageSourceCode
}
function Get-PageSourceCodeFromIE( [string] $QueryURL ) {
# This function takes advantage of your existing browser cookies.
# Get-PageSourceCodeFromIE https://twitter.com/cveira/status/275929500183830529
# WARNING: execution pre-condicion: no concurrency! No other IE instances should be running. They could be killed without saving!
$IE_READYSTATE_COMPLETE = 4
$TimeToWait = 3
$IE = New-Object -ComObject InternetExplorer.Application
$IE.Navigate($QueryURL)
while ($IE.ReadyState -ne $IE_READYSTATE_COMPLETE) {
Start-Sleep -Seconds $TimeToWait
}
$PageSourceCode = $IE.Document.body.innerHTML
$IE.Quit()
$IEClosedOk = ( [System.Runtime.Interopservices.Marshal]::ReleaseComObject( [System.__ComObject] $IE ) -eq 0 )
if ( !$IEClosedOk ) {
$IEProcess = Get-Process iexplore
$IEProcess | ForEach-Object { Stop-Process ( $_.id ) }
}
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()
$PageSourceCode
}