Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Visual Basic [игнор отключен] [закрыт для гостей] / Вопрос по заполнению формы / 13 сообщений из 13, страница 1 из 1
01.07.2011, 15:20
    #37332584
yuriy12
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Вопрос по заполнению формы
Прошу уважаемых форумчан помочь в решении небольшой задачки. Сразу скажу на форуме аналогичные вопросы были, но рабочего решения не нашел. Собственно вопрос:

Для автоматизации нужно автоматически заходить на сайт . Заполнить поля "логин/пароль" оказалось просто, а вот "нажать" на кнопку "Вход" не получилось :( Вероятно причина в реализации данных кнопок:

+

Код: plaintext
1.
<input name="login" type="hidden" id="login" value="submit"/>
<button type="submit" style="background-color:#dcbc89;border:0px;width:47px;height:94px;padding:0;margin:0;cursor:pointer;"><img src="/templates/Portal2/images/enter_02.jpg" alt="" border="0"/></button> 

То бишь и у "инпута", и у "баттона", нехвататет заветного параметра
Код: plaintext
onclick="submit();"

Пробовал так, но не понимает.

Код: plaintext
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.
    Set IE = CreateObject("InternetExplorer.Application")
 
    IE.Navigate "http://vipbook.info/"
 
    ' Wait while IE loading...
    Do While IE.Busy
        Application.Wait DateAdd("s",  1 , Now)
    Loop
 
    Set objCollection = IE.document.getElementsByTagName("input")
    
    For i= 0  to objCollection.Length
        Select Case (objCollection(i).Name)
        Case "login_name"
                objCollection(i).Value = "testtest"
        Case "login_password"
                objCollection(i).Value = "testtest"
        Case "login"
                 Set objElement = objCollection(i)
        End Select
    Next i
    
    objElement.Click
        
    ' Wait while IE loading...
    Do While IE.Busy
        Application.Wait DateAdd("s",  1 , Now)
    Loop

Подскажите, пожалуйста, как нажать на заветную кнопку? Заранее спасибо!
...
Рейтинг: 0 / 0
01.07.2011, 15:23
    #37332591
Konst_One
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Вопрос по заполнению формы
html этой вашей загруженной в браузер страницы сюда выложите, может тогда что и подскажем, а так гадание на кофейной гуще
...
Рейтинг: 0 / 0
01.07.2011, 16:02
    #37332678
yuriy12
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Вопрос по заполнению формы
Konst_One,

В принципе выше есть прямая ссылка, логин/пароль рабочие (специально зарегистрировал для теста). Но для упрощения фрагмент
HTML

Код: plaintext
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.
				<form method="post" onsubmit="javascript:showBusyLayer()" action=''> 
 
                   <div style="position:absolute; padding-top:33px;padding-left:23px;z-index:2;"> 
 
                   	<input type="text" name="login_name" value="Логин" class="login_input" onblur="if(this.value==''){this.value='Логин';}" onfocus="if(this.value=='Логин'){this.value='';}"/> 
 
                    </div> 
 
                    <div style="position:absolute; padding-top:50px;padding-left:23px;z-index:1;"> 
 
                       <input type="password" name="login_password" value="passwd" class="login_input" onblur="if(this.value==''){this.value='passwd';}" onfocus="if(this.value=='passwd'){this.value='';}"/> 
 
                    </div> 
 
                    <img src="/templates/Portal2/images/enter_01.jpg" alt=""/><input name="login" type="hidden" id="login" value="submit"/> 
 
                    <button type="submit" style="background-color:#dcbc89;border:0px;width:47px;height:94px;padding:0;margin:0;cursor:pointer;"><img src="/templates/Portal2/images/enter_02.jpg" alt="" border="0"/></button> 
                    
                    <!--<center><div style="position:absolute;"><a href="/index.php?do=feedback">Обратная связь</a></div></center>--> 
 
                    <td> 
 
                     <div style="position:absolute; padding-top:33px;padding-left:2px;z-index:2;"><a href="/index.php?do=register" class="simple" style="font-size:11px;"><noindex>Регистрация</noindex></a></div> 
 
                	 <div style="position:absolute; padding-top:50px;padding-left:2px;z-index:1;"><a href="/index.php?do=lostpassword" class="simple" style="font-size:11px;"><noindex>Забыли пароль?</noindex></a></div> 
                     
                     
                    <img src="/templates/Portal2/images/enter_03.jpg" alt="" border="0"/></td> 
                     </form> 
...
Рейтинг: 0 / 0
01.07.2011, 16:04
    #37332687
Konst_One
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Вопрос по заполнению формы
<form method=" post "

вам требуется выполнить POST-запрос по адресу этой страницы со всеми параметрами даной формы.
...
Рейтинг: 0 / 0
01.07.2011, 16:08
    #37332696
yuriy12
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Вопрос по заполнению формы
Konst_One<form method=" post "

вам требуется выполнить POST-запрос по адресу этой страницы со всеми параметрами даной формы.
"Хм, я не волшебник, я тольку учусь". Но за подсказку спасибо, пойду искать, что есть "POST-запрос"...
...
Рейтинг: 0 / 0
01.07.2011, 16:27
    #37332733
Konst_One
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Вопрос по заполнению формы
Код: plaintext
1.
2.
3.
Dim oHTTP As MSXML2.XMLHTTP
Set oHTTP = New MSXML2.XMLHTTP
oHTTP.Open "POST", "http://...", False
...
...
Рейтинг: 0 / 0
01.07.2011, 16:30
    #37332743
Konst_One
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Вопрос по заполнению формы
...
Рейтинг: 0 / 0
01.07.2011, 16:34
    #37332751
yuriy12
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Вопрос по заполнению формы
Konst_One, спасибо!

А это не оно? Авторизация на сайте средствами VB
Вроде и оно, но только у формы нет имени, как к ней обращаться? :(
...
Рейтинг: 0 / 0
01.07.2011, 16:35
    #37332753
Konst_One
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Вопрос по заполнению формы
...
Рейтинг: 0 / 0
01.07.2011, 16:36
    #37332755
скукотища
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Вопрос по заполнению формы
yuriy12,

Код: plaintext
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.
Option Explicit

Private Declare Sub Sleep Lib "kernel32" (ByVal lngPause%)

Sub NeedVIPBook()
Dim ie As Object

Set ie = CreateObject("internetexplorer.application")
ie.navigate "http://vipbook.info/"

Do While ie.busy
 Sleep  100 
Loop

ie.Visible = True

With ie.document.forms( 0 )

    .elements( 0 ).Value = "testtest"
    .elements( 1 ).Value = "testtest"
    .elements( 3 ).Click

End With
Set ie = Nothing

End Sub
...
Рейтинг: 0 / 0
02.07.2011, 19:05
    #37333849
yuriy12
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Вопрос по заполнению формы
скукотища,

У меня заработала следующая конструкция:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
Sub NeedVIPBook()
Dim ie As Object

Set ie = CreateObject("internetexplorer.application")
ie.navigate "http://vipbook.info/"
Do While ie.busy
    Application.Wait DateAdd("s",  1 , Now)
Loop
ie.Visible = True
With ie.document.forms( 0 )
    .elements( 0 ).Value = "testtest"
    .elements( 1 ).Value = "testtest"
    .elements( 3 ).Click
End With
Set ie = Nothing

End Sub

Почему-то на следующие строки программа выдает ошибку, возможно потому что запускаю код из-под экселя?
Код: plaintext
1.
2.
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal lngPause%)
Sleep  100 

Главное что работает, и теперь знаю как заполнять подобные формы. Спасибо большое!!!
...
Рейтинг: 0 / 0
03.07.2011, 01:14
    #37334058
Shocker.Pro
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Вопрос по заполнению формы
yuriy12Почему-то на следующие строки программа выдает ошибку, возможно потому что запускаю код из-под экселя?
Нет, потому что функцию (Sleep 100) надо запускать внутри какой-то процедуры, а не просто так
...
Рейтинг: 0 / 0
03.07.2011, 19:57
    #37334478
yuriy12
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Вопрос по заполнению формы
Еще вопрос по заполнению формы, правда на сей раз с другого сайта . Пользуясь полученными выше навыками, написал скрипт для автоматического входа на сайт и дальнейшего заполнения страницы "Добавить новость". Программа заходит на сайт, заполняет часть полей, но два поля упорно отказывается ("short_story" и "full_story"). Причем ошибок скрипт не выдает, но и поля не заполняет. Думаю виноват яваскрипт, но как его обойти?

Исходный текст формы (пришлось разбить на куски по типу):
Код: plaintext
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.
<form method=post name="entryform" id="entryform" onsubmit="document.getElementById('short_story').value = tinyMCE.get('short_story').getContent(); document.getElementById('full_story').value = tinyMCE.get('full_story').getContent(); if(document.entryform.title.value == '' || document.entryform.short_story.value == ''){alert('У вашей статьи должен быть хотя бы заголовок и краткая версия');return false}" action="">              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="10" align="left" valign="top"><img src="/templates/new/images/dlet_artblock_11.gif" width="10" height="8" /></td>
                  <td align="left" valign="top" class="a_block_12"><img src="/templates/new/images/spacer.gif" width="1" height="8" /></td>
                  <td width="10" align="right" valign="top"><img src="/templates/new/images/dlet_artblock_13.gif" width="10" height="8" /></td>
                </tr>
                <tr>
                  <td width="10" align="left" valign="top"><img src="/templates/new/images/dlet_artblock_21.gif" width="10" height="23" /></td>
                  <td align="left" valign="top" class="a_block_22"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="17" align="left" valign="top"><img src="/templates/new/images/dlet_artblock_22_01.gif" width="17" height="23" /></td>
                        <td align="left" class="ntitle">Публикация новости на сайте</td>
                        <td width="17" align="right" valign="top"><img src="/templates/new/images/dlet_artblock_22_03.gif" width="17" height="23" /></td>
                      </tr>
                    </table></td>
                  <td width="10" align="right" valign="top"><img src="/templates/new/images/dlet_artblock_23.gif" width="10" height="23" /></td>
                </tr>
                <tr>
                  <td width="10" align="left" valign="top"><img src="/templates/new/images/dlet_artblock_31.gif" width="10" height="9" /></td>
                  <td align="left" valign="top" class="a_block_32"><img src="/templates/new/images/spacer.gif" width="1" height="9" /></td>
                  <td width="10" align="right" valign="top"><img src="/templates/new/images/dlet_artblock_33.gif" width="10" height="9" /></td>
                </tr>
                <tr>
                  <td width="10" align="left" valign="top" class="a_block_61"> </td>
                  <td align="left" valign="top" class="slink"><br />

                    <table width="99%" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="110" height="25" nowrap="nowrap">Введите заголовок:</td>
                        <td><input type="text" name="title" value="" maxlength="150" class="f_input" /></td>
                      </tr>

                      <tr>
                        <td height="25">Категория:</td>
                        <td><select name="catlist[]" id="category" onchange="onCategoryChange(this.value)" style="width:220px;height:73px;" multiple><option value="0"></option><option style="color: black" value="1" >Главная</option><option style="color: black" value="2" >   Аудиокниги</option><option style="color: black" value="6" >   Книги</option><option style="color: black" value="5" >   Музыка</option><option style="color: black" value="4" >   Видео</option><option style="color: black" value="3" >   Анекдоты</option><option style="color: black" value="7" >   Игрушки</option><option style="color: black" value="8" >   Софт</option><option style="color: black" value="9" >Статьи</option><option style="color: black" value="10" >Упс</option></select></td>
                      </tr>

                      <tr>
                        <td>Краткое содержание:</td>
                        <td>
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
<script type="text/javascript" src="engine/editor/jscripts/tiny_mce/tiny_mce_gzip.js"></script>
<script type="text/javascript">
tinyMCE_GZ.init({
	plugins : "safari,advhr,advimage,emotions,inlinepopups,insertdatetime,media,searchreplace,print,contextmenu,paste,fullscreen,nonbreaking",
	themes : 'advanced',
	languages : 'ru',
	disk_cache : false,
	debug : false
});
</script>
Код: plaintext
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.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
<script type="text/javascript">
	tinyMCE.init({
		// General options
		mode : "exact",
		theme : "advanced",
		elements : "short_story,full_story",
		language : "ru",
		width : "98%",
		height : "400",
		plugins : "safari,advhr,advimage,emotions,inlinepopups,insertdatetime,media,searchreplace,print,contextmenu,paste,fullscreen,nonbreaking",
		auto_focus : "short_story",
		relative_urls : false,
		convert_urls : false,
		force_br_newlines : true,
        forced_root_block : '',
		force_p_newlines : false,
		dialog_type : 'window',
		extended_valid_elements : "div[align|class|style|id|title]",

		// Theme options
		theme_advanced_buttons1 : "cut,copy,|,paste,pastetext,pasteword,|,search,replace,|,outdent,indent,|,undo,redo,|,dle_upload,image,media,dle_mp,dle_mp3,emotions,|,dle_break,dle_page",
		theme_advanced_buttons2 : "fontselect,fontsizeselect,|,sub,sup,|,charmap,advhr,|,insertdate,inserttime,|,nonbreaking,dle_quote,dle_hide,dle_code,|,visualaid",
		theme_advanced_buttons3 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,dle_spoiler,|,link,dle_leech,|,forecolor,backcolor,|,removeformat,cleanup,|,code",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,
	   	plugin_insertdate_dateFormat : "%d-%m-%Y",
	    	plugin_insertdate_timeFormat : "%H:%M:%S",

		// Example content CSS (should be your site CSS)
		content_css : "http://web-lib.info/engine/editor/css/content.css",

		setup : function(ed) {
		        // Add a custom button
			ed.addButton('dle_quote', {
			title : 'Вставка цитаты',
			image : 'http://web-lib.info/engine/editor/jscripts/tiny_mce/themes/advanced/img/dle_quote.gif',
			onclick : function() {
				// Add you own code to execute something on click
				ed.execCommand('mceReplaceContent',false,'quote{$selection}/quote');
			}
	           });

			ed.addButton('dle_hide', {
			title : 'Скрытый текст',
			image : 'http://web-lib.info/engine/editor/jscripts/tiny_mce/themes/advanced/img/dle_hide.gif',
			onclick : function() {
				// Add you own code to execute something on click
				ed.execCommand('mceReplaceContent',false,'[hide]{$selection}[/hide]');
			}
	           });

			ed.addButton('dle_code', {
			title : 'Вставка исходного кода',
			image : 'http://web-lib.info/engine/editor/jscripts/tiny_mce/themes/advanced/img/dle_code.gif',
			onclick : function() {
				// Add you own code to execute something on click
				ed.execCommand('mceReplaceContent',false,'code{$selection}/code');
			}
	           });

			ed.addButton('dle_spoiler', {
			title : '',
			image : 'http://web-lib.info/engine/editor/jscripts/tiny_mce/themes/advanced/img/dle_spoiler.gif',
			onclick : function() {
				// Add you own code to execute something on click
				ed.execCommand('mceReplaceContent',false,'
{$selection}
'); } }); ed.addButton('dle_break', { title : 'Вставка разрыва между страницами', image : 'http://web-lib.info/engine/editor/jscripts/tiny_mce/themes/advanced/img/dle_break.gif', onclick : function() { // Add you own code to execute something on click ed.execCommand('mceInsertContent',false,'{PAGEBREAK}'); } }); ed.addButton('dle_page', { title : 'Вставка ссылки на страницу', image : 'http://web-lib.info/engine/editor/jscripts/tiny_mce/themes/advanced/img/dle_page.gif', onclick : function() { var enterURL = prompt("Введите номер страницы", "1"); var enterTITLE = prompt("Введите описание ссылки", ""); if (enterURL == null ) enterURL = "1"; if (enterTITLE == null ) enterTITLE = ""; ed.execCommand('mceInsertContent',false,"[page="+enterURL+"]"+enterTITLE+"[/page]"); } }); ed.addButton('dle_leech', { title : 'Вставка защищенной ссылки', image : 'http://web-lib.info/engine/editor/jscripts/tiny_mce/themes/advanced/img/dle_leech.gif', onclick : function() { var enterURL = prompt("Введите полный URL ссылки", "http://"); if (enterURL == null ) enterURL = "http://"; ed.execCommand('mceReplaceContent',false,"[leech="+enterURL+"]{$selection}[/leech]"); } }); ed.addButton('dle_mp', { title : 'Вставка видео (BB Codes)', image : 'http://web-lib.info/engine/editor/jscripts/tiny_mce/themes/advanced/img/dle_mp.gif', onclick : function() { var enterURL = prompt("Введите полный URL ссылки", "http://"); if (enterURL == null ) enterURL = "http://"; ed.execCommand('mceInsertContent',false,"[video="+enterURL+"]"); } }); ed.addButton('dle_upload', { title : 'Загрузка файлов на сервер', image : 'http://web-lib.info/engine/editor/jscripts/tiny_mce/themes/advanced/img/dle_upload.gif', onclick : function() { window.open('http://web-lib.info/engine/images.php?area=short_story&wysiwyg=yes&add_id=', '_Addimage', 'toolbar=0,location=0,status=0, left=0, top=0, menubar=0,scrollbars=yes,resizable=0,width=640,height=550'); } }); ed.addButton('dle_mp3', { title : '', image : 'http://web-lib.info/engine/editor/jscripts/tiny_mce/themes/advanced/img/dle_mp3.gif', onclick : function() { var enterURL = prompt("Введите полный URL ссылки", "http://"); if (enterURL == null ) enterURL = "http://"; ed.execCommand('mceInsertContent',false,"[audio="+enterURL+"]"); } }); } }); </script>
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
   <textarea id="short_story" name="short_story" rows= 10  cols= 50 ></textarea></td>
                      </tr>
                      <tr>
                        <td>Полная новость:<br />(необязательно)</td>
                        <td>    <br /><textarea id="full_story" name="full_story" rows= 10  cols= 50 ></textarea></td>
                      </tr>
                      <tr>
                        <td height="25" nowrap="nowrap">Ключевые слова<br />для облака тегов:</td>
                        <td><input type="text" name="tags" value="" maxlength="150" class="f_input" /></td>
                      </tr>
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
<script type="text/javascript">
<!--
  var item =  null ;
   if  (document.getElementById) {
    item = document.getElementById("category");
  }  else   if  (document.all) {
    item = document.all["category"];
  }  else   if  (document.layers) {
    item = document.layers["category"];
  }
   if  (item) {
    onCategoryChange(item.value);
  }
// -->
</script>
Код: plaintext
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.
            <tr>
                        <td>Код:</td>
                        <td><br /><span id="dle-captcha"><img src="/engine/modules/antibot.php" alt="Включите эту картинку для отображения кода безопасности" border="0"><br /><a onclick="reload(); return false;" href="#">обновить код</a></span></td>
                      </tr>
					  <tr>
                        <td>Введите код:</td>
                        <td><input type="text" name="sec_code" id="sec_code" style="width:115px" class="f_input" /></td>
                      </tr>

                      <tr>
                        <td width="110"> </td>
                        <td><input type="checkbox" name="allow_comm" value="1" checked>Разрешить комментарии    <input type="checkbox" name="allow_main" value="1" checked>Публиковать на главной<br><input type="checkbox" name="approve" value="1" checked> Опубликовать новость на сайте<br><input type="checkbox" name="allow_rating" value="1" checked> Разрешить рейтинг статьи</td>
                      </tr>
                      <tr>
                        <td width="110"> </td>
                        <td><input class="bbcodes_poll" type="submit" name="add" value="отправить" />  
                        <input class="bbcodes_poll" type="button" name="nview" onclick="preview()" value="просмотр" /></td>
                      </tr>
                    </table>

                  </td>
                  <td width="10" align="right" valign="top" class="a_block_63"> </td>
                </tr>
                <tr>
                  <td width="10" align="left" valign="top"><img src="/templates/new/images/dlet_artblock_71.gif" width="10" height="7" /></td>
                  <td align="left" valign="top" class="a_block_72"><img src="/templates/new/images/spacer.gif" width="1" height="7" /></td>
                  <td width="10" align="right" valign="top"><img src="/templates/new/images/dlet_artblock_73.gif" width="10" height="7" /></td>
                </tr>
                <tr>
                  <td width="10" align="left" valign="top"><img src="/templates/new/images/dlet_artblock_81.gif" width="10" height="14" /></td>
                  <td align="left" valign="top" class="a_block_82"> </td>
                  <td width="10" align="right" valign="top"><img src="/templates/new/images/dlet_artblock_83.gif" width="10" height="14" /></td>
                </tr>
              </table>
              <br /><input type="hidden" name="mod" value="addnews" /><input type="hidden" name="vuzvjypm" value="88ab990097183bbb632b2e06881b3b07" /></form>


И программный код:
Код: plaintext
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.
Sub web_lib_info()

    
    ' Create InternetExplorer Object
    Set IE = CreateObject("InternetExplorer.Application")
 
    IE.Navigate "http://web-lib.info/addnews.html"
 
    ' Wait while IE loading...
    Do While IE.Busy
        Application.Wait DateAdd("s",  1 , Now)
    Loop
 
    ' проверяем залогинились ли?
    need_login = False
    
    If IE.document.forms( 0 ).Elements( 0 ).Name = "login_name" Then
        need_login = True
    End If

    If need_login = True Then
        With IE.document.forms( 0 )
            .Elements("login_name").Value = "valera"
            .Elements("login_password").Value = "script"
            .submit
        End With
    
        Do While IE.Busy
            Application.Wait DateAdd("s",  1 , Now)
        Loop
    End If
    
    With IE.document.forms( 1 )
        .Elements("title").Value = "Заголовок"
        .Elements("short_story").Value = "Короткий текст"
        .Elements("full_story").Value = "Полный текст"
        .Elements("tags").Value = "Ключевые слова"
        .Elements("catlist[]").Value = "2"
    End With
    
    ' Wait while IE re-loading...
    Do While IE.Busy
        Application.Wait DateAdd("s",  1 , Now)
    Loop
 
    ' Clean up
    Set IE = Nothing
    Set objElement = Nothing
    Set objCollection = Nothing
 

End Sub


И второй вопрос - можно ли как-то с помощью VB вставить в эти два поля текст, сгенеренный HTML? Ну то есть по аналогии "нажать на кнопочку HTML в форме, и вставить данные".

Всем спасибо!
...
Рейтинг: 0 / 0
Форумы / Visual Basic [игнор отключен] [закрыт для гостей] / Вопрос по заполнению формы / 13 сообщений из 13, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]