200分紧急求助:修改(填充)网页的内容(属性)

ljluck7687 2012-02-02 02:20:38
1、网页中有textarea,想要修改其中的内容(html格式)。找到该元素后用 details.setAttribute('value',sHtml,0);
但是网页中的textarea值并未发生任何改变。因为它是一个网页编辑器,而不是纯粹的textarea。这时候要如何才能知道 这个网页编辑器是什么,比如说是ckeditor,还是其他的?知道后又如何用代码填充编辑器的内容呢?(是html格式)
2、网页中有大量诸如<div class="info-title fd-clr mod mod-offer-post-title" data-mod-config='{"formGroup":"title","validateDanger":"http://sss.com/offer/post/json/validate_result.htm"}'>之类的代码,如何控制data-mod-config中的属性呢?网页中有些div中有许多表单元素,但在网页中根本无法遍历,因为它是由data-mod-config控制的。所以请高人指点,如何处理这种情况,以便能自由填充表单元素?
3、如何控制网页中的json数据?
4、<div class="img-cont third"><img class="cont-img" /></div> 这时img的图片为空,如何使这个img能够显示指定的图像?

以上4个问题请用delphi代码解答,只要你能正确解答,你要多少分数我都会给你!!!

真诚希望高手友情支援,预备2000分奉送!!!
...全文
419 31 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
31 条回复
切换为时间正序
请发表友善的回复…
发表回复
ljluck7687 2012-02-10
  • 打赏
  • 举报
回复
第一个问题已经解决,请参考相关帖子!!!
ljluck7687 2012-02-10
  • 打赏
  • 举报
回复
特别感谢二憨朋友的帮助,不过还有第二个问题没有解决!
继续请各位大侠帮忙啊!
山东蓝鸟贵薪 2012-02-06
  • 打赏
  • 举报
回复
顶顶帖子

ljluck7687 2012-02-06
  • 打赏
  • 举报
回复
顶起来,。。。
ljluck7687 2012-02-06
  • 打赏
  • 举报
回复
大牛哪去了呢?2000分都不感兴趣吗?
ljluck7687 2012-02-04
  • 打赏
  • 举报
回复
楼上的朋友,当然没有这么简单。否则也不可能要高人相助了。
erhan 2012-02-03
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 ljluck7687 的回复:]
下面是图片部分和textarea部分的源代码:

<ol class="imgs">
<li>
<div class="img-cont"><img src="http://i03.c.aliimg.com/img/ibank/2011/599/600/434006995_1371677574.jpg" class="cont-img" /></div>
<div class="ctrl……
[/Quote]

先挣点分分,呵呵。2种方法设置了TextArea的内容(注意:方法2中的setAttribute里的VALUE需要全大写,吼吼)

弱弱地问一句,这个回答如果满足了你的要求,算是完成了整个问题的的1/4了,可以得200分不。呵呵


unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls, MSHtml, IdBaseComponent,
IdComponent, IdTCPConnection, IdTCPClient, IdHTTP;

type
TForm1 = class(TForm)
wb1: TWebBrowser;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
wb1.Navigate('http://localhost:12880/mtm/textarea.htm');
end;

procedure TForm1.Button1Click(Sender: TObject);
var
doc: IHTMLDocument2;
mTextArea: IHTMLTextAreaElement;
begin
doc := wb1.Document as IHTMLDocument2;

mTextArea := doc.all.item('offer-content',0) as IHTMLTextAreaElement;
mTextArea.value := 'abc';
end;

procedure TForm1.Button2Click(Sender: TObject);
var
doc: IHTMLDocument2;
mTextArea: IHTMLElement;
begin
doc := wb1.Document as IHTMLDocument2;

mTextArea := doc.all.item('offer-content',0) as IHTMLElement;
mTextArea.setAttribute('VALUE','ccc',0);
end;

end.
ljluck7687 2012-02-03
  • 打赏
  • 举报
回复
下面是图片部分和textarea部分的源代码:

<ol class="imgs">
<li>
<div class="img-cont"><img src="http://i03.c.aliimg.com/img/ibank/2011/599/600/434006995_1371677574.jpg" class="cont-img" /></div>
<div class="ctrl">
<a href="#remove" title="删除">删除</a>
</div>
</li>
<li>
<div class="img-cont second"><img class="cont-img" /></div>
<div class="ctrl">
<a href="#remove" title="删除">删除</a>
</div>
</li>
<li>
<div class="img-cont third"><img class="cont-img" /></div>
<div class="ctrl">
<a href="#remove" title="删除">删除</a>
</div>
</li>
</ol>
<div class="pic-helper">推荐使用免费工具“图片助手”,自动处理图片格式及大小并上传!  
<a href="http://offer.china.alibaba.com/offer/post/img_manage_adv_upload_picture.htm?id=0&type=sale" id="bd_img_helper" paramid="100" parampath="">立即使用</a>  
<a class="pic-helpdoc" href="http://service.china.alibaba.com/kf/detail/2953049.html">帮助</a>
</div>
<div id="picHelperErrorMsg" class="pic-helper"></div>
</div>
</div>
</div>
<input type="hidden" id="picture1" name="pictureUrl" value="" />
<input type="hidden" id="picture2" name="pictureUrl" value="" />
<input type="hidden" id="picture3" name="pictureUrl" value="" />
<input type="hidden" name="picture_widget" value="true"/>
</div>
<div class="mod mod-offer-post-video fd-clr" data-mod-config='{"vasUrl":"http://vas.china.alibaba.com/"}'>
<div id="vas_video_wrap"></div>
<input type="hidden" id="offer_video_getvid" name="videoVId" value=""/>
<input type="hidden" id="offer_video_state" name="videoState" value=""/>
<input type="hidden" id="offer_video_id" name="videoId" value=""/>
<input type="hidden" name="video_widget" value="true"/>
</div>
<div class="detail-info fd-clr mod mod-offer-post-detail"
data-mod-config='{"formGroup":"detail","fetch_piccount_url":"http://picman.china.alibaba.com/album/ajax/album_get_count_detail.json","fetch_piclist_url":"http://picman.china.alibaba.com/album/ajax/image_detail_list.json","fetch_albumlist_url":"http://picman.china.alibaba.com/album/ajax/album_puller_ajax.json","upload_url":"http://picman.china.alibaba.com/album/ajax/image_upload_ajax.json?_input_charset=UTF-8","fetch_summinfo_url":"http://picman.china.alibaba.com/album/ajax/album_global_info_ajax.json","new_album_url":"http://picman.china.alibaba.com/album/ajax/create_album.json"}'>
<div class="form-line">
<div class="form-title">详细说明:<a name="详细说明"> </a></div>
<div class="form-context">
<div class="note">请从产品性能、用途、包装、售后服务等方面来描述,建议您在详细说明中插入产品细节图</div>
<div class="form_editor">
<textarea id="offer-content" name="details" value="" data-proname="详细说明" ></textarea>
</div>
<div class="detail-err"></div>
<div class="note">
<p>1、插入图片时请勿盗用他人图片、以免引起纠纷。<a href="http://service.china.alibaba.com/kf/detail/3222594.html">如何在详细说明中插入图片?</a></p>
</div>
</div>
</div>
爱蹄子的羊头 2012-02-03
  • 打赏
  • 举报
回复


{实在是不懂, 只能帮顶了}

{弱弱问一句, 用 JS脚本可以不?}

ljluck7687 2012-02-03
  • 打赏
  • 举报
回复
<div class="form-line">
<div class="err">请填写 信息标题</div>
</div>
<input type="hidden" name="title_widget" value="true"/>
</div>
<div class="mod mod-offer-post-properties fd-clr"
data-mod-config='{"formGroup":"properties","leafCategoryName":"不锈钢圆钢","tradeType":"1","categoryId":"1035767","featureUrl":"http://china.alibaba.com/offer/post/json/feature_parameters.htm","levelInfoUrl":"http://gene.china.alibaba.com/spu/ajax/get_level_info_by_path.htm","spuInfoUrl":"http://gene.china.alibaba.com/spu/ajax/get_spu_info_by_key_attr.htm","suggestionUrl":"http://pubsuggest.china.alibaba.com/bin/spu_suggest","productFeatureList":[{"childrenFids":[],"featureIdValues":[{"value":"201","vid":20439},{"value":"202","vid":20432},{"value":"301","vid":20045},{"value":"304","vid":20047},{"value":"304L","vid":18605},{"value":"308","vid":20049},{"value":"309","vid":20051},{"value":"309S","vid":18669},{"value":"310S","vid":18921},{"value":"316","vid":20011},{"value":"316L","vid":18971},{"value":"317L","vid":18951},{"value":"321","vid":20029},{"value":"329","vid":20023},{"value":"347","vid":20002},{"value":"409","vid":19580},{"value":"409L","vid":23385},{"value":"410","vid":19598},{"value":"410S","vid":21444},{"value":"420","vid":19612},{"value":"430","vid":19633},{"value":"439","vid":19635},{"value":"444","vid":19652},{"value":"其他","vid":15590}],"featureType":"0;","fid":287,"fieldType":"enum","inputType":1,"isKeyAttr":false,"isNeeded":"Y","isSpecAttr":false,"isSpecExtendedAttr":false,"isSuggestion":false,"isSupportDefinedValues":false,"name":"材质","order":1},{"childrenFids":[],"featureIdValues":[{"value":"MMK","vid":6094},{"value":"安钢","vid":916},{"value":"鞍钢","vid":22905},{"value":"鞍山宝得","vid":14637},{"value":"包钢","vid":3243},{"value":"宝钢","vid":209},{"value":"宝新","vid":22093},{"value":"本钢","vid":21752},{"value":"春冶","vid":10195},{"value":"大庚","vid":14445},{"value":"达钢","vid":19330},{"value":"德钢","vid":24050},{"value":"蒂森克虏伯","vid":100008449},{"value":"鄂钢","vid":3921},{"value":"抚钢","vid":8763},{"value":"韩国浦项","vid":15629},{"value":"沪宝","vid":7419},{"value":"黄河特钢","vid":10903},{"value":"济钢","vid":2628},{"value":"酒钢","vid":4455},{"value":"莱钢","vid":17555},{"value":"联众","vid":29712},{"value":"马钢","vid":8717},{"value":"攀钢","vid":2856},{"value":"青钢","vid":23613},{"value":"日钢","vid":6377},{"value":"上海克虏伯","vid":100008448},{"value":"首钢","vid":5922},{"value":"唐钢","vid":9415},{"value":"太钢","vid":19257},{"value":"天钢","vid":19272},{"value":"天铁","vid":19256},{"value":"通钢","vid":323},{"value":"武钢","vid":9009},{"value":"舞钢","vid":11765},{"value":"湘钢","vid":5629},{"value":"兴澄","vid":25033},{"value":"新日铁","vid":395},{"value":"张浦","vid":34130},{"value":"其他","vid":15590}],"featureType":"0;","fid":4221,"fieldType":"enum","inputType":1,"isKeyAttr":false,"isNeeded":"Y","isSpecAttr":false,"isSpecExtendedAttr":false,"isSuggestion":false,"isSupportDefinedValues":false,"name":"产地/厂家","order":2},{"childrenFids":[],"featureIdValues":[{"value":"热轧","vid":19491},{"value":"冷拉","vid":24597},{"value":"锻制","vid":10683},{"value":"其他","vid":15590}],"featureType":"0;","fid":3545,"fieldType":"enum","inputType":1,"isKeyAttr":false,"isNeeded":"Y","isSpecAttr":false,"isSpecExtendedAttr":false,"isSuggestion":false,"isSupportDefinedValues":false,"name":"制作工艺","order":3},{"childrenFids":[],"featureIdValues":[{"value":"Φ30","vid":100007208},{"value":"Φ35","vid":100008515},{"value":"Φ40","vid":100007314},{"value":"Φ45","vid":100007181},{"value":"Φ50","vid":100007209},{"value":"Φ55","vid":100008516},{"value":"Φ60","vid":100007210},{"value":"Φ65","vid":100008517},{"value":"Φ70","vid":100008518},{"value":"Φ75","vid":100007182},{"value":"Φ80","vid":100007228},{"value":"Φ85","vid":100007229},{"value":"Φ90","vid":100007183},{"value":"Φ95","vid":100008519},{"value":"Φ100","vid":100007230}],"featureType":"0;","fid":1234,"fieldType":"enum","inputType":2,"isKeyAttr":false,"isNeeded":"Y","isSpecAttr":true,"isSpecExtendedAttr":false,"isSuggestion":false,"isSupportDefinedValues":true,"name":"规格","order":5,"unit":"mm"},{"childrenFids":[],"featureIdValues":[],"featureType":"0;","fid":100018713,"fieldType":"string","inputType":0,"isKeyAttr":false,"isNeeded":"N","isSpecAttr":false,"isSpecExtendedAttr":false,"isSuggestion":false,"isSupportDefinedValues":false,"name":"仓库","order":4}] }'>
<div class="form-line fd-clr">
<div class="form-title">产品属性:<a name="产品属性"> </a></div>
<div class="form-context">
<div class="note">完整的产品属性有助于买家找到您的信息</div>
<div class="product-props"><img align="absmiddle" src="http://i04.c.aliimg.com/images/myalibaba/trade/100524/loading.gif"> 正在加载属性信息,请稍候..</div>
</div>
</div>
<div class="form-line fd-clr supmod-product-speca-props">
<div class="form-title">产品规格:<a name="产品规格"> </a></div>
<div class="form-context">
<div class="product-speca-props"></div>
</div>
</div>
<input type="hidden" id="isApplySpu" name="isApplySpu" value="false"/>
<input type="hidden" id="hasUseSpu" name="hasUseSpu" value="false"/>
<input type="hidden" id="isStandardSpu" name="isStandardSpu" value="false"/>
<input type="hidden" id="spuId" name="spuId" value=""/>
<input type="hidden" name="categoryId" value="1035767"/>
<input type="hidden" name="product_feature_widget" value="true"/>
</div>
<div class="mod mod-offer-post-trade-info" data-mod-config='{"formGroup":"tradeInfo","money":"元","isOpenETC":"false","isRealPriceCat":"false"}'>
<a name="交易信息"> </a>
ljluck7687 2012-02-03
  • 打赏
  • 举报
回复
网页源代码如下:(基于隐私等原则,只取了部分源代码)
注意:网页源代码仅属于学术研究性质,我们之间的讨论也属于学术研究性质,与所示的网站无关,谢谢合作!

<!doctype html>
<html>
<head>
<meta charset="gbk"/>
<title>欢迎光临</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link rel="shortcut icon" href="http://i02.c.aliimg.com/favicon.ico">
<link href="http://style.china.alibaba.com/app/offer/css/postoffer/global/postoffer-merge.css" rel="stylesheet"/>
<link href="http://style.china.alibaba.com/app/offer/css/postoffer/page/fill-product-info-merge.css" rel="stylesheet"/>
<link href="http://img.s.aliimg.com/vaspool/video/css/vas_video_base.css" type="text/css" rel="stylesheet" />
<link href="http://style.china.alibaba.com/app/offer/css/module/widget/videoComponents.css" type="text/css" rel="stylesheet">
<base target="_blank"/>
</head>
<body ><script type=text/javascript src="http://style.china.alibaba.com/js/common/beacon.js"></script> <script type=text/javascript>var dmtrack_c='{-}'; var dmtrack_pageid='db86fdb66e4bc4361328063439'; sk_dmtracking();</script> <noscript><img src="http://dmtracking.alibaba.com/b.jpg?cD0yJnU9ey9vZmZlci5jaGluYS5hbGliYWJhLmNvbS9vZmZlci9wb3N0L2ZpbGxfcHJvZHVjdF9pbmZvLmh0bX0mbT17UE9TVH0mcz17MjAwfSZyPXtodHRwOi8vb2ZmZXIuY2hpbmEuYWxpYmFiYS5jb20vb2ZmZXIvcG9zdC9jaG9vc2VfY2F0ZWdvcnkuaHRtP30mYT17XFxcImNfbXM9MXxjX210PTN8Y19taWQ9bWZ0c2d8Y19saWQ9bWZ0c2dcXFwifSZiPXstfSZjPXstfQ==&ver=40&pageid=db86fdb66e4bc4361328063439&time=1328063439" width="1" height="1" style="display:none"></noscript>
<div id="doc" class="w952"
data-doc-config='{"isGroupOffer":false,"submitUrl":"http://offer.china.alibaba.com/offer/post/fill_product_info.htm","submitData":{"_csrf_token":"3c3e94a748bbb84bd6b653915344d6d8","action":"OfferPostAction","isGroupOffer":false,"tradeType":"1","topCategoryId":"9","secondCategoryId":"10518","thirdCategoryId":"1035767","operator":"new","fromWhere":"","adGroupId":"","productId":""}}'>


<div id="content" class="content">
<div class="content-tit">
<div class="fd-left"><h2> 发布供应产品 </h2></div>
<div class="fd-right guide">
<span><em>1</em>选择类目</span>
<span class="arrow current"><em>2</em>填写产品详情</span>
<span class="arrow"><em>3</em>提交成功,等待审核</span>
</div>
</div>

<div class="content-con">
<div class="tit">
<div class="fd-left">
<h3 class="nomargin">您选择的类目:</h3>
<span>
冶金矿产
>
不锈钢材
>
不锈钢圆钢
</span>
<span class="mod mod-offer-post-recate" data-mod-config='{"isGroupOffer":"false"}'>
<form class="fd-hide" target="_self" name="returnChooseCategoryFrom" action="http://offer.china.alibaba.com/offer/post/choose_category.htm" method="post">
<input type="hidden" name="tradeType" value="1"/>
<input type="hidden" name="topCategoryId" id="topCategoryId" value="9"/>
<input type="hidden" name="secondCategoryId" id="secondCategoryId" value="10518"/>
<input type="hidden" name="thirdCategoryId" id="thirdCategoryId" value="1035767"/>
<input type="hidden" name="isGroupOffer" value="false"/>
<input type="hidden" name="operator" value="new"/>
<input type="hidden" name="offerId" value="0"/>
<input type="hidden" name="productId" value=""/>
<input type="hidden" name="fromWhere" value=""/>
<input type="hidden" name="adGroupId" value=""/>
<input name='_csrf_token' type='hidden' value='3c3e94a748bbb84bd6b653915344d6d8'>
</form>
</span>
<span class="note">返回重选类目会造成已填写的信息丢失,请慎重操作!</span>
</div>
</div>
<!--提交后错误信息提示-->

<div class="mod mod-offer-post-info sys-info" data-mod-config=''>
</div>


<div class="tit">
<div class="fd-left">
<h3>填写基本信息</h3><a name="基本信息"> </a>

<span class="note">对本类目下产品属性和计量单位有改进建议,</span>
<a class="icon-feedback feedback-default" href="http://club.china.alibaba.com/forum/thread/add.html?forum_id=100757&hint=%D2%B1%BD%F0%BF%F3%B2%FA%26nbsp%3B%26gt%3B%26nbsp%3B%B2%BB%D0%E2%B8%D6%B2%C4%26nbsp%3B%26gt%3B%26nbsp%3B%B2%BB%D0%E2%B8%D6%D4%B2%B8%D6%3Cbr%3E%CE%D2%B6%D4%B5%B1%C7%B0%C0%E0%C4%BF%B5%C4%BD%A8%D2%E9%CA%C7%3A">我要反馈</a>

</div>
<div class="fd-right">
<span class="icon-must note">表示该项必填</span>
</div>
</div>
<div class="info-title fd-clr mod mod-offer-post-title" data-mod-config='{"formGroup":"title","validateDanger":"http://china.alibaba.com/offer/post/json/validate_result.htm"}'>
<div class="form-line">
<div class="form-title"><span class="icon-must">信息标题:<a name="信息标题"> </a></span></div>
<div class="form-context">
<div class="fd-left"><input name="subject" class="info-title-txt txt" type="text" value="" ></div>
<div class="note fd-left">最长30个汉字(60个字符),建议在标题中包含产品名称和相应关键词</div>
</div>
</div>
ljluck7687 2012-02-03
  • 打赏
  • 举报
回复
谢谢7楼的朋友,你的代码对我没有用。

不好意思,刚才有点忙,还未发新贴。
lzg827 2012-02-03
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 ljluck7687 的回复:]
好的,我新开了一个帖,请大家看新开的帖!
[/Quote]

楼主,新帖在哪里?发个链接
Jekhn 2012-02-03
  • 打赏
  • 举报
回复

//uses MSHTML, SHDocVw, ActiveX
doWithHtmlElement(aElementCollection:IHTMLElementCollection);
var
k:integer;
vk:oleVariant;
Dispatch: IDispatch;
HTMLInputElement:IHTMLInputElement;
HTMLSelectElement:IHTMLSelectElement;
HTMLOptionElement: IHTMLOptionElement;
HTMLTextAreaElement: IHTMLTextAreaElement;
HTMLFormElement:IHTMLFormElement;
HTMLOptionButtonElement:IHTMLOptionButtonElement;
begin
for k:=0 to aElementCollection.length -1 do
begin
Vk:=k;
Dispatch:=aElementCollection.item(Vk,0);
if Succeeded(Dispatch.QueryInterface(IHTMLInputElement,HTMLInputElement)) then
begin
With HTMLInputElement do
begin
if (UpperCase(Type_)='TEXT') or (UpperCase(Type_)='PASSWORD') then
begin
value:='text';
end
else if (UpperCase(Type_)='CHECKBOX') then
begin
checked:=true;
end
else if (UpperCase(Type_)='RADIO') then
begin
checked :=true;
end;
end;
end
else if Succeeded(Dispatch.QueryInterface(IHTMLSelectElement,HTMLSelectElement)) then
begin
With HTMLSelectElement do
begin
selectedIndex :=1;
end;
end
else if Succeeded(Dispatch.QueryInterface(IHTMLTEXTAreaElement,HTMLTextAreaElement)) then
begin
with HTMLTextAreaElement do
begin
value :='textarea';
end;
end
else if Succeeded(Dispatch.QueryInterface(IHTMLOptionElement,HTMLOptionElement)) then
begin
with HTMLOptionElement do
begin

end;
end
else if SUCCEEDED(Dispatch.QueryInterface(IHTMLFormElement,HTMLFormElement))then
begin
with HTMLFormElement do
begin

end;
end
else if SUCCEEDED(Dispatch.QueryInterface(IHTMLOptionButtonElement,HTMLOptionButtonElement))then
begin

end
else
;
end;
end;

不知道这是不是楼主想要的?
ljluck7687 2012-02-03
  • 打赏
  • 举报
回复
好的,我新开了一个帖,请大家看新开的帖!
z109876543210 2012-02-03
  • 打赏
  • 举报
回复
非要搞这么复杂么?

delphi执行js函数不就好了
EmbeddedWB1.OleObject.document.parentWindow.your_js_function();
erhan 2012-02-03
  • 打赏
  • 举报
回复
说实话,我到现在也没搞清楚,你要的是什么。
ljluck7687 2012-02-03
  • 打赏
  • 举报
回复
顶起来,求高人帮忙!
ljluck7687 2012-02-03
  • 打赏
  • 举报
回复
首先一点,这些元素在页面中找不到(不是显式定义的,而是调用的),你又如何发送按键?另外对于超大的Html内容总不可能发送按键吧
haitao 2012-02-03
  • 打赏
  • 举报
回复
只提一个思路:使用消息发送按键来填。。。。。。。。。
加载更多回复(11)

1,594

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧