youtuber Posted October 20, 2017 Share Posted October 20, 2017 (edited) Hello, what is the counterpart of these codes? Please write similar code in C # and VB.net. Thanks expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $ScriptDir = @ScriptDir If StringRight($ScriptDir, 1) <> "\" Then $ScriptDir &= "\" Global $aReadsFile = $ScriptDir & "Source.txt" Global $aOpenFile = FileOpen($aReadsFile,1) $Form1 = GUICreate("Form1", 748, 652) $Edit1 = GUICtrlCreateEdit("" & @CRLF, 16, 40, 401, 457, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") GUICtrlSendMsg($Edit1, $EM_LIMITTEXT, -1, 0) $Edit2 = GUICtrlCreateEdit("" & @CRLF, 432, 40, 240, 457, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") GUICtrlSendMsg($Edit2, $EM_LIMITTEXT, -1, 0) $aRegex = GUICtrlCreateInput('(?i)href="(.*?)utm_campaign', 592, 574, 121, 21) $CheckData = GUICtrlCreateButton("Check Data", 16, 552, 107, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $CheckData $aRegex = GUICtrlRead($aRegex) Local $array = StringSplit(GUICtrlRead($Edit1), @CRLF, 1) For $i = 1 To $array[0] $string = Connect($array[$i]) If @error Then ConsoleWrite("Connection Error") ExitLoop EndIf $aData = StringRegExp($string, $aRegex,1) For $j = 0 To UBound($aData) - 1 FileWrite($aOpenFile, $aData[$j] & @CRLF) GUICtrlSetData($Edit2, FileRead($aReadsFile)) Next Next EndSwitch WEnd Func Connect($address) Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", $address, False) $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0") $oHTTP.SetRequestHeader("Accept", "*/*") $oHTTP.SetRequestHeader("Accept-Language", "tr-TR,tr;q=0.8,en-US;q=0.5,en;q=0.3") $oHTTP.Send() If @error Then ConsoleWrite("Error connection") $oHTTP = 0 Return SetError(1) EndIf If $oHTTP.Status = 200 Then Local $sReceived = $oHTTP.ResponseText $oHTTP = Null Return $sReceived EndIf $oHTTP = Null Return -1 EndFunc Edited October 20, 2017 by youtuber Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 20, 2017 Moderators Share Posted October 20, 2017 @youtuber what have you tried on your own to convert? You have been around long enough to know that we operate on the "teach a man to fish" motto, rather than you putting in a request and someone spoon-feeding the code to you. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
youtuber Posted October 20, 2017 Author Share Posted October 20, 2017 yes but not very well expandcollapse popupusing System.Text.RegularExpressions; using System.Threading; using System.Windows.Forms; public bool SplitData(string AnswerFrom) { MatchCollection m1 = Regex.Matches(AnswerFrom, "(?i)href="(.*?)utm_campaign", RegexOptions.Singleline); } public static string SendRequest(string Data) { try { HttpWebRequest Request = (HttpWebRequest) WebRequest.Create(Urlread); Request.ContentType = "application/x-www-form-urlencoded"; Request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0"; Request.Method = "GET"; byte[] bytes = Encoding.ASCII.GetBytes(Data); Request.ContentLength = bytes.Length; Stream stream = Request.GetRequestStream(); stream.Write(bytes, 0, bytes.Length); stream.Close(); var AnswerFrom = Request.GetResponse(); if (AnswerFrom != null) { StreamReader sr = new StreamReader(AnswerFrom.GetResponseStream()); return sr.ReadToEnd().Trim(); } else { return ""; } } catch { return ""; } } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now