Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Get-Token
- {
- param($editURL)
- $lines = $editURL.content.Split("\n")
- foreach($line in $lines)
- {
- if($line -match "value=`"$userID,")
- {
- $token = $line.Split("`"")[2]
- break
- }
- }
- return $token
- }
- # user information
- $username = "oma sähköposti"
- $password = "oma salasana"
- $userID = "oma userid"
- $site = "http://murobbs.muropaketti.com/"
- # body for login
- $body = @{
- login = $username
- password = $password
- cookie_check = $true
- redirect = "/"
- _xfToken = $null
- }
- # login and get session
- $login = Invoke-RestMethod -Method Post -Uri "$site/login/login" -SessionVariable session -Body $body
- # get first 20 posts from all post view
- $threadsPage = Invoke-WebRequest -Uri "$site/search/member?user_id=$userID" -WebSession $session
- # get search ID (this ID changes every time)
- $searchPath = $threadsPage.BaseResponse.ResponseUri.LocalPath.Substring(1, $threadsPage.BaseResponse.ResponseUri.LocalPath.Length-2)
- # get post ID's from the first page
- $postsIDs = ($threadsPage.ParsedHtml.getElementsByTagName('li') | where {$_.id -like "post-*"}).id -replace "post-",""
- # go through each page and append the IDs to the postsIDs array
- foreach($i in 2..10)
- {
- $threadsPage = Invoke-WebRequest -Uri "$site$searchPath/?page=$i" -WebSession $session
- $postsIDs += ($threadsPage.ParsedHtml.getElementsByTagName('li') | where {$_.id -like "post-*"}).id -replace "post-",""
- }
- # go through all postIDs
- foreach($postID in $postsIDs)
- {
- # url content for token
- $editURL = Invoke-WebRequest -Uri "$site/posts/$postID" -WebSession $session
- # get token
- $token = Get-Token -editURL $editURL
- # edit post data
- $data = @{
- "message_html" = "poisto"
- "_xfToken" = $token
- }
- # edit post
- $res = Invoke-WebRequest -Uri "$site/posts/$postID/save" -WebSession $session -Method Post -Body $data
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement