Bienvenido/a al foro, pero... ¿en que lenguaje de programación lo tienes pensado hacer?
Saludos!
Saludos!
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes MenúCita de: luis456 en 30 Marzo 2015, 18:42 PMEl valor no puede ser nulo.
Nombre del parámetro: second
Dim col1 As IEnumerable(Of String) = {}
Dim col2 As IEnumerable(Of String) ' = Nothing
Dim concatCol As IEnumerable(Of String) = Enumerable.Concat(first:=col1, second:=col2)
Cita de: Saito_25 en 30 Marzo 2015, 12:36 PMqué hago mal?
numero = gets.chomp # String
numero = numero.to_i # Integer
# O la asignación de un valor Integer directamente convirtiendo la entrada de datos del teclado...
# numero = gets.chomp.to_i
if numero < 100
print "#{numero} es menor a 100."
end
numero = gets.chomp # String
if numero.to_i < 100
print "#{numero} es menor a 100."
end
Cita de: Kaxperday en 29 Marzo 2015, 23:39 PM¿Que puedo estar pasando por alto?, saludos y gracias.
HttpUtility.UrlEncode(usuario);
HttpUtility.UrlEncode(contraseña);
''' <summary>
''' Gets the main url.
''' </summary>
''' <value>The main url.</value>
Public ReadOnly Property UrlMain As String
Get
Return "http://www.cgwallpapers.com/"
End Get
End Property
''' <summary>
''' Gets the login url.
''' </summary>
''' <value>The login url.</value>
Public ReadOnly Property UrlLogin As String
Get
Return "http://www.cgwallpapers.com/login.php"
End Get
End Property
''' <summary>
''' Gets the login query string format.
''' </summary>
''' <value>The login query string format.</value>
Public ReadOnly Property UrlLoginQueryFormat As String
Get
Return "usuario={0}&contrasena={1}"
End Get
End Property
''' <summary>
''' Gets the headers for a Login POST request.
''' </summary>
''' <value>The headers for a Login POST request.</value>
Public ReadOnly Property RequestHeadersPostLogin As WebHeaderCollection
Get
Dim headers As New WebHeaderCollection
With headers
.Add("Accept-Language", "en-us,en;q=0.5")
.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7")
.Add("Keep-Alive", "99999")
End With
Return headers
End Get
End Property
''' <summary>
''' Determines whether the user is logged in the site.
''' </summary>
Private isLogged As Boolean
''' <summary>
''' Gets the cookie container.
''' </summary>
''' <value>The cookie container.</value>
Public ReadOnly Property CookieCollection As CookieCollection
Get
Return Me.cookieCollection1
End Get
End Property
''' <summary>
''' The cookie container.
''' </summary>
Private cookieCollection1 As CookieCollection
''' <summary>
''' Defines the query data for a LoginPost request.
''' </summary>
Private NotInheritable Class LoginQueryData
''' <summary>
''' Gets the Usuario field.
''' </summary>
''' <value>The Usuario field.</value>
Public Property Usuario As String
''' <summary>
''' Gets or sets the Conteasena field.
''' </summary>
''' <value>The Conteasena field.</value>
Public Property Contrasena As String
End Class
''' <summary>
''' Gets a formatted <see cref="String"/> representation of a <see cref="LoginQueryData"/> object.
''' </summary>
''' <param name="loginQueryData">The <see cref="LoginQueryData"/> object that contains the login query fields.</param>
''' <returns>A formatted <see cref="String"/> representation of a <see cref="LoginQueryData"/> object.</returns>
Private Function GetLoginQueryString(ByVal loginQueryData As LoginQueryData) As String
Return String.Format(Me.UrlLoginQueryFormat,
loginQueryData.Usuario,
loginQueryData.Contrasena)
End Function
''' <summary>
''' Sets the cookie container.
''' </summary>
''' <param name="url">The url.</param>
''' <param name="cookieCollection">The cookie collection.</param>
''' <returns>CookieContainer.</returns>
Private Function SetCookieContainer(ByVal url As String,
ByVal cookieCollection As CookieCollection) As CookieContainer
Dim cookieContainer As New CookieContainer
Dim refDate As Date
For Each oldCookie As Cookie In cookieCollection
If Not DateTime.TryParse(oldCookie.Value, refDate) Then
Dim newCookie As New Cookie
With newCookie
.Name = oldCookie.Name
.Value = oldCookie.Value
.Domain = New Uri(url).Host
.Secure = False
End With
cookieContainer.Add(newCookie)
End If
Next oldCookie
Return cookieContainer
End Function
''' <summary>
''' Converts cookie string to global cookie collection object.
''' </summary>
''' <param name="cookie">The cookie string.</param>
''' <param name="cookieCollection">The cookie collection.</param>
Private Sub SaveCookies(ByVal cookie As String,
ByRef cookieCollection As CookieCollection)
Dim cookieStrings() As String = cookie.Trim.
Replace("path=/,", String.Empty).
Replace("path=/", String.Empty).
Split({";"c}, StringSplitOptions.RemoveEmptyEntries)
cookieCollection = New CookieCollection
For Each cookieString As String In cookieStrings
If Not String.IsNullOrEmpty(cookieString.Trim) Then
cookieCollection.Add(New Cookie(name:=cookieString.Trim.Split("="c)(0),
value:=cookieString.Trim.Split("="c)(1)))
End If
Next cookieString
End Sub
''' <summary>
''' Convert cookie container object to global cookie collection object.
''' </summary>
''' <param name="cookieContainer">The cookie container.</param>
''' <param name="cookieCollection">The cookie collection.</param>
''' <param name="url">The url.</param>
Private Sub SaveCookies(ByVal cookieContainer As CookieContainer,
ByRef cookieCollection As CookieCollection,
ByVal url As String)
cookieCollection = New CookieCollection
For Each cookie As Cookie In cookieContainer.GetCookies(New Uri(url))
cookieCollection.Add(cookie)
Next cookie
End Sub
''' <param name="url">The url.</param>
''' <param name="cookieCollection">The cookie collection.</param>
''' <returns><c>true</c> if successfull, <c>false</c> otherwise.</returns>
Private Function GetMethod(ByVal url As String,
ByRef cookieCollection As CookieCollection) As Boolean
Debug.WriteLine("[+] GetMethod function started.")
Dim request As HttpWebRequest = Nothing
Dim response As HttpWebResponse = Nothing
Dim sr As StreamReader = Nothing
Dim result As Boolean = False
Try
Debug.WriteLine("[+] Attempting to perform a request with:")
Debug.WriteLine(String.Format("Method: {0}", "GET"))
Debug.WriteLine(String.Format("Headers: {0}", String.Join(Environment.NewLine, Me.RequestHeadersPostLogin)))
request = DirectCast(HttpWebRequest.Create(url), HttpWebRequest)
With request
.Method = "GET"
.Headers = Me.RequestHeadersPostLogin
.Accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0"
.AllowAutoRedirect = False
.KeepAlive = True
End With
Debug.WriteLine("[-] Request done.")
' Get the server response.
Debug.WriteLine("[+] Getting server response...")
response = DirectCast(request.GetResponse, HttpWebResponse)
Debug.WriteLine("[-] Getting server response done.")
If request.HaveResponse Then
' Save the cookie info.
Debug.WriteLine("[+] Saving cookies...")
Me.SaveCookies(response.Headers("Set-Cookie"), cookieCollection)
Debug.WriteLine("[-] Saving cookies done.")
' Get the server response.
Debug.WriteLine("[+] Getting server response...")
response = DirectCast(request.GetResponse, HttpWebResponse)
Debug.WriteLine("[-] Getting server response done.")
Debug.WriteLine("[+] Reading server response...")
sr = New StreamReader(response.GetResponseStream)
Using sr
' Read the response from the server, but we do not save it.
sr.ReadToEnd()
End Using
result = True
Debug.WriteLine("[-] Reading server response done.")
Else ' No response received from server.
Throw New Exception(String.Format("No response received from server with url: {0}", url))
result = False
End If
Catch ex As Exception
Throw
result = False
Finally
If sr IsNot Nothing Then
sr.Dispose()
End If
If response IsNot Nothing Then
response.Close()
End If
End Try
Debug.WriteLine("[-] GetMethod function finished.")
Debug.WriteLine("[i] Returning result value...")
Return result
End Function
''' <param name="loginData">The login post data.</param>
''' <param name="cookieCollection">The cookie collection.</param>
''' <returns><c>true</c> if successfull, <c>false</c> otherwise.</returns>
Private Function PostLoginMethod(ByVal loginData As LoginQueryData,
ByRef cookieCollection As CookieCollection) As Boolean
Debug.WriteLine("[+] PostLoginMethod function started.")
Dim request As HttpWebRequest = Nothing
Dim response As HttpWebResponse = Nothing
Dim sw As StreamWriter = Nothing
Dim initialCookieCount As Integer = 0
Dim postData As String
Dim result As Boolean = False
Try
Debug.WriteLine("[+] Attempting to perform a login request with:")
Debug.WriteLine(String.Format("Method: {0}", "POST"))
Debug.WriteLine(String.Format("Referer: {0}", Me.UrlMain))
Debug.WriteLine(String.Format("Accept: {0}", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"))
Debug.WriteLine(String.Format("ContentType: {0}", "application/x-www-form-urlencoded"))
Debug.WriteLine(String.Format("Headers: {0}", String.Join(Environment.NewLine, Me.RequestHeadersPostLogin)))
request = DirectCast(HttpWebRequest.Create(Me.UrlLogin), HttpWebRequest)
With request
.Method = "POST"
.Headers = Me.RequestHeadersPostLogin
.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
.ContentType = "application/x-www-form-urlencoded"
.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0"
.Referer = Me.UrlMain
End With
Debug.WriteLine("[-] Request done.")
Debug.WriteLine("[+] Passing request cookie info...")
If cookieCollection IsNot Nothing Then ' Pass cookie info from the login page.
request.CookieContainer = Me.SetCookieContainer(Me.UrlLogin, cookieCollection)
End If
Debug.WriteLine("[-] Passing request cookie info done.")
' Set the post data.
Debug.WriteLine("[+] Setting post data with:")
Debug.WriteLine(String.Format("Usuario: {0}", loginData.Usuario))
Debug.WriteLine(String.Format("Contrasena: {0}", loginData.Contrasena))
postData = Me.GetLoginQueryString(loginData)
sw = New StreamWriter(request.GetRequestStream)
Using sw
sw.Write(postData) ' Post the data to the server.
End Using
Debug.WriteLine("[-] Setting post data done.")
' Get the server response.
Debug.WriteLine("[+] Getting server response...")
initialCookieCount = request.CookieContainer.Count
response = DirectCast(request.GetResponse, HttpWebResponse)
Debug.WriteLine("[-] Getting server response done.")
If request.CookieContainer.Count > initialCookieCount Then ' Login successful.
result = True
Else ' Login unsuccessful.
result = False
End If
Debug.WriteLine(String.Format("[i] Login response result is: {0}",
If(result, "Successful (True)",
"Unsuccessful (False)")))
If result Then ' Save new login cookies.
Debug.WriteLine("[+] Saving new login cookies...")
Me.SaveCookies(request.CookieContainer, cookieCollection, Me.UrlMain)
Debug.WriteLine("[-] Saving new login cookies done.")
End If
Catch ex As Exception
Throw
Finally
If sw IsNot Nothing Then
sw.Dispose()
End If
If response IsNot Nothing Then
response.Close()
End If
End Try
Debug.WriteLine("[-] PostLoginMethod function finished.")
Debug.WriteLine("[i] Returning result value...")
Me.isLogged = result
Return result
End Function
''' <summary>
''' Determines whether the account can log in CGWallpapers site.
''' </summary>
''' <returns><c>true</c> if the account can log in CGWallpapers site, <c>false</c> otherwise.</returns>
Public Function CheckLogin(ByVal username As String,
ByVal password As String) As Boolean
If Me.GetMethod(Me.UrlMain, Me.cookieCollection1) Then
Dim loginQueryData As New LoginQueryData With
{
.Usuario = HttpUtility.UrlEncode(username),
.Contrasena = HttpUtility.UrlEncode(password)
}
Return Me.PostLoginMethod(loginQueryData, Me.cookieCollection1)
Else
Return False
End If ' Me.GetMethod
End Function
/// <summary>
/// Gets the main url.
/// </summary>
/// <value>The main url.</value>
public string UrlMain {
get { return "http://www.cgwallpapers.com/"; }
}
/// <summary>
/// Gets the login url.
/// </summary>
/// <value>The login url.</value>
public string UrlLogin {
get { return "http://www.cgwallpapers.com/login.php"; }
}
/// <summary>
/// Gets the login query string format.
/// </summary>
/// <value>The login query string format.</value>
public string UrlLoginQueryFormat {
get { return "usuario={0}&contrasena={1}"; }
}
/// <summary>
/// Gets the headers for a Login POST request.
/// </summary>
/// <value>The headers for a Login POST request.</value>
public WebHeaderCollection RequestHeadersPostLogin {
get {
WebHeaderCollection headers = new WebHeaderCollection();
var _with1 = headers;
_with1.Add("Accept-Language", "en-us,en;q=0.5");
_with1.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
_with1.Add("Keep-Alive", "99999");
return headers;
}
}
/// <summary>
/// Determines whether the user is logged in the site.
/// </summary>
private bool isLogged;
/// <summary>
/// Gets the cookie container.
/// </summary>
/// <value>The cookie container.</value>
public CookieCollection CookieCollection {
get { return this.cookieCollection1; }
}
/// <summary>
/// The cookie container.
/// </summary>
private CookieCollection cookieCollection1;
/// <summary>
/// Defines the query data for a LoginPost request.
/// </summary>
private sealed class LoginQueryData
{
/// <summary>
/// Gets the Usuario field.
/// </summary>
/// <value>The Usuario field.</value>
public string Usuario { get; set; }
/// <summary>
/// Gets or sets the Conteasena field.
/// </summary>
/// <value>The Conteasena field.</value>
public string Contrasena { get; set; }
}
/// <summary>
/// Gets a formatted <see cref="String"/> representation of a <see cref="LoginQueryData"/> object.
/// </summary>
/// <param name="loginQueryData">The <see cref="LoginQueryData"/> object that contains the login query fields.</param>
/// <returns>A formatted <see cref="String"/> representation of a <see cref="LoginQueryData"/> object.</returns>
private string GetLoginQueryString(LoginQueryData loginQueryData)
{
return string.Format(this.UrlLoginQueryFormat, loginQueryData.Usuario, loginQueryData.Contrasena);
}
/// <summary>
/// Sets the cookie container.
/// </summary>
/// <param name="url">The url.</param>
/// <param name="cookieCollection">The cookie collection.</param>
/// <returns>CookieContainer.</returns>
private CookieContainer SetCookieContainer(string url, CookieCollection cookieCollection)
{
CookieContainer cookieContainer = new CookieContainer();
System.DateTime refDate = default(System.DateTime);
foreach (Cookie oldCookie in cookieCollection) {
if (!DateTime.TryParse(oldCookie.Value, refDate)) {
Cookie newCookie = new Cookie();
var _with2 = newCookie;
_with2.Name = oldCookie.Name;
_with2.Value = oldCookie.Value;
_with2.Domain = new Uri(url).Host;
_with2.Secure = false;
cookieContainer.Add(newCookie);
}
}
return cookieContainer;
}
/// <summary>
/// Converts cookie string to global cookie collection object.
/// </summary>
/// <param name="cookie">The cookie string.</param>
/// <param name="cookieCollection">The cookie collection.</param>
private void SaveCookies(string cookie, ref CookieCollection cookieCollection)
{
string[] cookieStrings = cookie.Trim.Replace("path=/,", string.Empty).Replace("path=/", string.Empty).Split({ ';' }, StringSplitOptions.RemoveEmptyEntries);
cookieCollection = new CookieCollection();
foreach (string cookieString in cookieStrings) {
if (!string.IsNullOrEmpty(cookieString.Trim)) {
cookieCollection.Add(new Cookie(name: cookieString.Trim.Split('=')(0), value: cookieString.Trim.Split('=')(1)));
}
}
}
/// <summary>
/// Convert cookie container object to global cookie collection object.
/// </summary>
/// <param name="cookieContainer">The cookie container.</param>
/// <param name="cookieCollection">The cookie collection.</param>
/// <param name="url">The url.</param>
private void SaveCookies(CookieContainer cookieContainer, ref CookieCollection cookieCollection, string url)
{
cookieCollection = new CookieCollection();
foreach (Cookie cookie in cookieContainer.GetCookies(new Uri(url))) {
cookieCollection.Add(cookie);
}
}
/// <param name="url">The url.</param>
/// <param name="cookieCollection">The cookie collection.</param>
/// <returns><c>true</c> if successfull, <c>false</c> otherwise.</returns>
private bool GetMethod(string url, ref CookieCollection cookieCollection)
{
Debug.WriteLine("[+] GetMethod function started.");
HttpWebRequest request = null;
HttpWebResponse response = null;
StreamReader sr = null;
bool result = false;
try {
Debug.WriteLine("[+] Attempting to perform a request with:");
Debug.WriteLine(string.Format("Method: {0}", "GET"));
Debug.WriteLine(string.Format("Headers: {0}", string.Join(Environment.NewLine, this.RequestHeadersPostLogin)));
request = (HttpWebRequest)HttpWebRequest.Create(url);
var _with3 = request;
_with3.Method = "GET";
_with3.Headers = this.RequestHeadersPostLogin;
_with3.Accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
_with3.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0";
_with3.AllowAutoRedirect = false;
_with3.KeepAlive = true;
Debug.WriteLine("[-] Request done.");
// Get the server response.
Debug.WriteLine("[+] Getting server response...");
response = (HttpWebResponse)request.GetResponse;
Debug.WriteLine("[-] Getting server response done.");
if (request.HaveResponse) {
// Save the cookie info.
Debug.WriteLine("[+] Saving cookies...");
this.SaveCookies(response.Headers("Set-Cookie"), ref cookieCollection);
Debug.WriteLine("[-] Saving cookies done.");
// Get the server response.
Debug.WriteLine("[+] Getting server response...");
response = (HttpWebResponse)request.GetResponse;
Debug.WriteLine("[-] Getting server response done.");
Debug.WriteLine("[+] Reading server response...");
sr = new StreamReader(response.GetResponseStream);
using (sr) {
// Read the response from the server, but we do not save it.
sr.ReadToEnd();
}
result = true;
Debug.WriteLine("[-] Reading server response done.");
// No response received from server.
} else {
throw new Exception(string.Format("No response received from server with url: {0}", url));
result = false;
}
} catch (Exception ex) {
throw;
result = false;
} finally {
if (sr != null) {
sr.Dispose();
}
if (response != null) {
response.Close();
}
}
Debug.WriteLine("[-] GetMethod function finished.");
Debug.WriteLine("[i] Returning result value...");
return result;
}
/// <param name="loginData">The login post data.</param>
/// <param name="cookieCollection">The cookie collection.</param>
/// <returns><c>true</c> if successfull, <c>false</c> otherwise.</returns>
private bool PostLoginMethod(LoginQueryData loginData, ref CookieCollection cookieCollection)
{
Debug.WriteLine("[+] PostLoginMethod function started.");
HttpWebRequest request = null;
HttpWebResponse response = null;
StreamWriter sw = null;
int initialCookieCount = 0;
string postData = null;
bool result = false;
try {
Debug.WriteLine("[+] Attempting to perform a login request with:");
Debug.WriteLine(string.Format("Method: {0}", "POST"));
Debug.WriteLine(string.Format("Referer: {0}", this.UrlMain));
Debug.WriteLine(string.Format("Accept: {0}", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"));
Debug.WriteLine(string.Format("ContentType: {0}", "application/x-www-form-urlencoded"));
Debug.WriteLine(string.Format("Headers: {0}", string.Join(Environment.NewLine, this.RequestHeadersPostLogin)));
request = (HttpWebRequest)HttpWebRequest.Create(this.UrlLogin);
var _with4 = request;
_with4.Method = "POST";
_with4.Headers = this.RequestHeadersPostLogin;
_with4.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
_with4.ContentType = "application/x-www-form-urlencoded";
_with4.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0";
_with4.Referer = this.UrlMain;
Debug.WriteLine("[-] Request done.");
Debug.WriteLine("[+] Passing request cookie info...");
// Pass cookie info from the login page.
if (cookieCollection != null) {
request.CookieContainer = this.SetCookieContainer(this.UrlLogin, cookieCollection);
}
Debug.WriteLine("[-] Passing request cookie info done.");
// Set the post data.
Debug.WriteLine("[+] Setting post data with:");
Debug.WriteLine(string.Format("Usuario: {0}", loginData.Usuario));
Debug.WriteLine(string.Format("Contrasena: {0}", loginData.Contrasena));
postData = this.GetLoginQueryString(loginData);
sw = new StreamWriter(request.GetRequestStream);
using (sw) {
sw.Write(postData);
// Post the data to the server.
}
Debug.WriteLine("[-] Setting post data done.");
// Get the server response.
Debug.WriteLine("[+] Getting server response...");
initialCookieCount = request.CookieContainer.Count;
response = (HttpWebResponse)request.GetResponse;
Debug.WriteLine("[-] Getting server response done.");
// Login successful.
if (request.CookieContainer.Count > initialCookieCount) {
result = true;
// Login unsuccessful.
} else {
result = false;
}
Debug.WriteLine(string.Format("[i] Login response result is: {0}", result ? "Successful (True)" : "Unsuccessful (False)"));
// Save new login cookies.
if (result) {
Debug.WriteLine("[+] Saving new login cookies...");
this.SaveCookies(request.CookieContainer, ref cookieCollection, this.UrlMain);
Debug.WriteLine("[-] Saving new login cookies done.");
}
} catch (Exception ex) {
throw;
} finally {
if (sw != null) {
sw.Dispose();
}
if (response != null) {
response.Close();
}
}
Debug.WriteLine("[-] PostLoginMethod function finished.");
Debug.WriteLine("[i] Returning result value...");
this.isLogged = result;
return result;
}
/// <summary>
/// Determines whether the account can log in CGWallpapers site.
/// </summary>
/// <returns><c>true</c> if the account can log in CGWallpapers site, <c>false</c> otherwise.</returns>
public bool CheckLogin(string username, string password)
{
if (this.GetMethod(this.UrlMain, this.cookieCollection1)) {
LoginQueryData loginQueryData = new LoginQueryData {
Usuario = HttpUtility.UrlEncode(username),
Contrasena = HttpUtility.UrlEncode(password)
};
return this.PostLoginMethod(loginQueryData, this.cookieCollection1);
} else {
return false;
}
// Me.GetMethod
}
//=======================================================
//Service provided by Telerik (www.telerik.com)
//=======================================================
Cita de: light310oct en 29 Marzo 2015, 23:04 PM
Yo tengo una duda sobre algo que he intentado hacer con VB6.0 y nada mas no he podido sera que lo podre hacer con un batch?, la idea es agregar datos entre la ultima etiqueta "</tr>"y la etiqueta "</table>"a fin de ir armandome una tabla con datos de una variable
@Echo OFF & SetLocal EnableDelayedExpansion
Set "chars=qrstuvwxyz"
Set /P "text=Introduce el valor: "
REM Tus evaluaciones aquí.
REM ej: If "%text%" EQU "" ()...
For /L %%# In (0, 1, 9) Do (
Set "char=!chars:~%%#,1!"
Call Set "text=!text:%%#=%%char%%!"
)
Start /B "url" "http://www.misitio.com/generar.index.jsp?id=%text%"
Pause&Exit /B 0
Dim c1 As String
Dim c2 As String
Dim c3 As String
Dim c4 As String
Dim c5 As String
Dim c6 As String
Dim c7 As String
Dim c8 As String
Dim c9 As String
Dim c10 As String
Dim c11 As String
Dim c12 As String
Dim c13 As String
Dim c14 As String
Dim c15 As String
Dim c16 As String
Dim c17 As String
Dim c18 As String
Dim c19 As String
Dim c20 As String
Dim c21 As String
Dim c22 As String
Dim c23 As String
Dim c24 As String
Dim c25 As String
Dim c26 As String
Dim c27 As String
Dim c28 As String
Dim c29 As String
Dim c30 As String
Dim c31 As String
Dim c32 As String
Dim c33 As String
Dim c34 As String
Dim c35 As String
Dim c36 As String
Dim c37 As String
Dim c38 As String
Dim c39 As String
Dim c40 As String
Dim c41 As String
Dim c42 As String
Dim c43 As String
Dim c44 As String
Dim c45 As String
Dim c46 As String
Dim c47 As String
Dim c48 As String
Dim c49 As String
Do While tmp1 <= var1.Length
If var2(tmp1) = Nothing Then
var2(tmp1) = 0
End If
If var3(tmp1) = Nothing Then
var3(tmp1) = 0
End If
If var4(tmp1) = Nothing Then
var4(tmp1) = 0
End If
If var5(tmp1) = Nothing Then
var5(tmp1) = 0
End If
If var6(tmp1) = Nothing Then
var6(tmp1) = 0
End If
If var7(tmp1) = Nothing Then
var7(tmp1) = 0
End If
If var8(tmp1) = Nothing Then
var8(tmp1) = 0
End If
If var9(tmp1) = Nothing Then
var9(tmp1) = 0
End If
If var10(tmp1) = Nothing Then
var10(tmp1) = 0
End If
If var11(tmp1) = Nothing Then
var11(tmp1) = 0
End If
If var12(tmp1) = Nothing Then
var12(tmp1) = 0
End If
tmp1 += 1
Loop
Do While i <= var1.Length
c1 = <a><![CDATA[<v:sampleDataSet dataSetName="]]></a>.Value & "datos" & i & <a><![CDATA[">]]></a>.Value
c2 = <a><![CDATA[<]]></a>.Value & nombre1 & <a><![CDATA[>]]></a>.Value
c3 = <a><![CDATA[<p>]]></a>.Value & var1(i) & <a><![CDATA[</p>]]></a>.Value
c4 = <a><![CDATA[</]]></a>.Value & nombre1 & <a><![CDATA[>]]></a>.Value
c5 = <a><![CDATA[<v:sampleDataSet dataSetName="]]></a>.Value & "datos" & i & <a><![CDATA[">]]></a>.Value
c6 = <a><![CDATA[<]]></a>.Value & nombre2 & <a><![CDATA[>]]></a>.Value
c7 = <a><![CDATA[<p>]]></a>.Value & var2(i) & <a><![CDATA[</p>]]></a>.Value
c8 = <a><![CDATA[</]]></a>.Value & nombre2 & <a><![CDATA[>]]></a>.Value
c9 = <a><![CDATA[<v:sampleDataSet dataSetName="]]></a>.Value & "datos" & i & <a><![CDATA[">]]></a>.Value
c10 = <a><![CDATA[<]]></a>.Value & nombre3 & <a><![CDATA[>]]></a>.Value
c11 = <a><![CDATA[<p>]]></a>.Value & var3(i) & <a><![CDATA[</p>]]></a>.Value
c12 = <a><![CDATA[</]]></a>.Value & nombre3 & <a><![CDATA[>]]></a>.Value
c13 = <a><![CDATA[<v:sampleDataSet dataSetName="]]></a>.Value & "datos" & i & <a><![CDATA[">]]></a>.Value
c14 = <a><![CDATA[<]]></a>.Value & nombre4 & <a><![CDATA[>]]></a>.Value
c15 = <a><![CDATA[<p>]]></a>.Value & var4(i) & <a><![CDATA[</p>]]></a>.Value
c16 = <a><![CDATA[</]]></a>.Value & nombre4 & <a><![CDATA[>]]></a>.Value
c17 = <a><![CDATA[<v:sampleDataSet dataSetName="]]></a>.Value & "datos" & i & <a><![CDATA[">]]></a>.Value
c18 = <a><![CDATA[<]]></a>.Value & nombre5 & <a><![CDATA[>]]></a>.Value
c19 = <a><![CDATA[<p>]]></a>.Value & var5(i) & <a><![CDATA[</p>]]></a>.Value
c20 = <a><![CDATA[</]]></a>.Value & nombre5 & <a><![CDATA[>]]></a>.Value
c21 = <a><![CDATA[<v:sampleDataSet dataSetName="]]></a>.Value & "datos" & i & <a><![CDATA[">]]></a>.Value
c22 = <a><![CDATA[<]]></a>.Value & nombre6 & <a><![CDATA[>]]></a>.Value
c23 = <a><![CDATA[<p>]]></a>.Value & var6(i) & <a><![CDATA[</p>]]></a>.Value
c24 = <a><![CDATA[</]]></a>.Value & nombre6 & <a><![CDATA[>]]></a>.Value
c25 = <a><![CDATA[<v:sampleDataSet dataSetName="]]></a>.Value & "datos" & i & <a><![CDATA[">]]></a>.Value
c26 = <a><![CDATA[<]]></a>.Value & nombre7 & <a><![CDATA[>]]></a>.Value
c27 = <a><![CDATA[<p>]]></a>.Value & var7(i) & <a><![CDATA[</p>]]></a>.Value
c28 = <a><![CDATA[</]]></a>.Value & nombre7 & <a><![CDATA[>]]></a>.Value
c29 = <a><![CDATA[<v:sampleDataSet dataSetName="]]></a>.Value & "datos" & i & <a><![CDATA[">]]></a>.Value
c30 = <a><![CDATA[<]]></a>.Value & nombre8 & <a><![CDATA[>]]></a>.Value
c31 = <a><![CDATA[<p>]]></a>.Value & var8(i) & <a><![CDATA[</p>]]></a>.Value
c32 = <a><![CDATA[</]]></a>.Value & nombre8 & <a><![CDATA[>]]></a>.Value
c33 = <a><![CDATA[<v:sampleDataSet dataSetName="]]></a>.Value & "datos" & i & <a><![CDATA[">]]></a>.Value
c34 = <a><![CDATA[<]]></a>.Value & nombre9 & <a><![CDATA[>]]></a>.Value
c35 = <a><![CDATA[<p>]]></a>.Value & var9(i) & <a><![CDATA[</p>]]></a>.Value
c36 = <a><![CDATA[</]]></a>.Value & nombre9 & <a><![CDATA[>]]></a>.Value
c37 = <a><![CDATA[<v:sampleDataSet dataSetName="]]></a>.Value & "datos" & i & <a><![CDATA[">]]></a>.Value
c38 = <a><![CDATA[<]]></a>.Value & nombre10 & <a><![CDATA[>]]></a>.Value
c39 = <a><![CDATA[<p>]]></a>.Value & var10(i) & <a><![CDATA[</p>]]></a>.Value
c40 = <a><![CDATA[</]]></a>.Value & nombre10 & <a><![CDATA[>]]></a>.Value
c41 = <a><![CDATA[<v:sampleDataSet dataSetName="]]></a>.Value & "datos" & i & <a><![CDATA[">]]></a>.Value
c42 = <a><![CDATA[<]]></a>.Value & nombre11 & <a><![CDATA[>]]></a>.Value
c43 = <a><![CDATA[<p>]]></a>.Value & var11(i) & <a><![CDATA[</p>]]></a>.Value
c44 = <a><![CDATA[</]]></a>.Value & nombre11 & <a><![CDATA[>]]></a>.Value
c45 = <a><![CDATA[<v:sampleDataSet dataSetName="]]></a>.Value & "datos" & i & <a><![CDATA[">]]></a>.Value
c46 = <a><![CDATA[<]]></a>.Value & nombre12 & <a><![CDATA[>]]></a>.Value
c47 = <a><![CDATA[<p>]]></a>.Value & var12(i) & <a><![CDATA[</p>]]></a>.Value
c48 = <a><![CDATA[</]]></a>.Value & nombre12 & <a><![CDATA[>]]></a>.Value
c49 = <a><![CDATA[</v:sampleDataSet>]]></a>.Value
Cuerpo_xml = Cuerpo_xml & vbCrLf & c1 & vbCrLf & c2 & vbCrLf & c3 & vbCrLf & c4 & vbCrLf & c5 & _
vbCrLf & c6 & vbCrLf & c7 & vbCrLf & c8 & vbCrLf & c9 & vbCrLf & c10 & _
vbCrLf & c11 & vbCrLf & c12 & vbCrLf & c13 & vbCrLf & c14 & vbCrLf & c15 & _
vbCrLf & c16 & vbCrLf & c17 & vbCrLf & c18 & vbCrLf & c19 & vbCrLf & c20 & _
vbCrLf & c21 & vbCrLf & c22 & vbCrLf & c23 & vbCrLf & c24 & vbCrLf & c25 & _
vbCrLf & c26 & vbCrLf & c27 & vbCrLf & c28 & vbCrLf & c29 & vbCrLf & c30 & _
vbCrLf & c31 & vbCrLf & c32 & vbCrLf & c33 & vbCrLf & c34 & vbCrLf & c35 & _
vbCrLf & c36 & vbCrLf & c37 & vbCrLf & c38 & vbCrLf & c39 & vbCrLf & c40 & _
vbCrLf & c41 & vbCrLf & c42 & vbCrLf & c43 & vbCrLf & c44 & vbCrLf & c45 & _
vbCrLf & c46 & vbCrLf & c47 & vbCrLf & c48 & vbCrLf & c49 & vbCrLf
i += 1
Loop
Dim arrays As IEnumerable(Of Array) =
{
var1, var2, var3,
var4, var5, var6,
var7, var8, var9,
var10, var11, var12
}
Dim count As Integer = 0
Dim sb As New System.Text.StringBuilder
With sb
For Each arr As Array In arrays
For Each value As String In arr
count += 1
.AppendLine(String.Format("<v:sampleDataSet dataSetName=""datos {0}"">", CStr(count)))
.AppendLine(String.Format("<{0}>", nombre1))
.AppendLine(String.Format("<p>{0}</p>", value))
.AppendLine(String.Format("</{0}>", nombre1))
.AppendLine()
Next value
Next arr
End With
Dim xmlText As String = Me.cuerpo_xml & sb.ToString & Me.fin_xml
Cita de: Saito_25 en 29 Marzo 2015, 12:37 PMTampoco sé si hay alguna diferencia entre el código mío y ese, si cambiará en algo el resultado a corto o largo plazo.
Citarlibros.sort! { |primerLibro, segundoLibro| primerLibro <=> segundoLibro }
Cita de: Saito_25 en 29 Marzo 2015, 12:37 PMSigo sin entender muy bien ese código.
# -*- coding: WINDOWS-1252 -*-
col = [ "d", "a", "e", "c", "b" ]
ascendantCol =
col.sort {
|a, b|
case
when a > b
+1
when b > a
-1
else
0
end
}
descendantCol =
col.sort {
|a, b|
case
when a > b
-1
when b > a
+1
else
0
end
}
print "Ascendant : #{ ascendantCol.join(', ')}\n"
print "Descendant: #{descendantCol.join(', ')}\n"
__END__
Citar(splits(3).Concat(splits(10).Concat(splits(11).Concat(splits(12).
Distinct.
Select(Function(Value As Integer)
Return If(Value < MAX, Value, Rand1.Next(1, MAX))
End Function)))))
(splits(3).Concat(splits(10)).Concat(splits(11)).Concat(splits(12))).
Distinct.
Select(Function(value As Integer)
Return If(Value < MAX, Value, Rand1.Next(1, MAX))
End Function)
Dim concatCol As IEnumerable(Of Integer) = col1.Concat(col2)
Dim distinctCol As IEnumerable(Of Integer) = concatCol.Distinct
Dim selectCol As IEnumerable(Of Integer) = distinctCol.Select(Function(value As Integer)
If value < max Then
Return value
Else
Return rand.Next(1, max)
End If
End Function)