在LR中怎么模拟下载动作?

在LR中怎么模拟下载动作?本文由技术开发部供稿,转载请注明。

#include "as_web.h"
Action()
{
long i,fp;
 web_add_cookie("sid=26CE7C; DOMAIN=www.test-edu.com");

 web_add_cookie("_cookietime=31536000; DOMAIN=www.test-edu.net");

 web_add_cookie("_discuz_uid=2327; DOMAIN=www.test-edu.com");

 web_add_cookie("_discuz_pw=6cd9c1d7e2498582eddcf7a91a936c06; DOMAIN=www.test-edu.net");

 web_add_cookie("_discuz_secques=6ccf9bcd; DOMAIN=www.test-edu.net");

 web_add_cookie("oldtopics=%096342%09; DOMAIN=www.test-edu.net");

 web_url("www.test-edu.com",
  "URL=http://www.test-edu.net/",
  "Resource=0",
  "RecContentType=text/html",
  "Referer=",
  "Snapshot=t4.inf",
  "Mode=HTML",
  LAST);

 web_url("opsdirective.xml",
  "URL=http://toolbar.msn.com/static/msntbs15/opsdirective.xml?type=2",
  "Resource=0",
  "RecContentType=text/xml",
  "Referer=",
  "Snapshot=t5.inf",
  "Mode=HTML",
  LAST);

 web_url("index.htm",
  "URL=http://www.test-edu.com/index/index.htm",
  "Resource=0",
  "RecContentType=text/html",
  "Referer=",
  "Snapshot=t6.inf",
  "Mode=HTML",
  EXTRARES,
  "Url=lib/flash/logo.swf", "Referer=", ENDITEM,
  "Url=lib/flash/title.swf", "Referer=", ENDITEM,
  "Url=../common/lib/liuchengxx1.swf", "Referer=", ENDITEM,
  LAST);

 web_link("51Testing软件测试论坛",
  "Text=51Testing软件测试论坛",
  "Snapshot=t7.inf",
  EXTRARES,
  "Url=images/default/bg.gif", ENDITEM,
  "Url=flash/title.swf", "Referer=", ENDITEM,
  "Url=images/default/headerbg.gif", ENDITEM,
  "Url=images/default/catbg.gif", ENDITEM,
  LAST);

 lr_think_time( 3 );

 web_link("[LoadRunner]",
  "Text=[LoadRunner]",
  "Snapshot=t8.inf",
  EXTRARES,
  "Url=images/default/bg.gif", "Referer=http://www.test-edu.net/cgi-bin/forumdisplay.php?fid=67", ENDITEM,
  "Url=flash/title.swf", "Referer=", ENDITEM,
  "Url=images/default/headerbg.gif", "Referer=http://www.test-edu.net/cgi-bin/forumdisplay.php?fid=67", ENDITEM,
  LAST);

 lr_think_time( 1 );

 web_link("我编写了一个小脚本,其中讲叙了怎样做关联,怎样写custom request供大家参考",
  "Text=我编写了一个小脚本,其中讲叙了怎样做关联,怎样写custom request供大家参考",
  "Snapshot=t9.inf",
  EXTRARES,
  "Url=images/default/bg.gif", "Referer=http://www.test-edu.net/cgi-bin/viewthread.php?tid=13860&fpage=1", ENDITEM,
  "Url=flash/title.swf", "Referer=", ENDITEM,
  "Url=images/default/headerbg.gif", "Referer=http://www.test-edu.net/cgi-bin/viewthread.php?tid=13860&fpage=1", ENDITEM,
  LAST);


 lr_start_transaction("DownLoad");
    fp = fopen("c:\\flight.rar","wb");
    web_set_max_html_param_len("500000");
    web_reg_save_param("FILED","LB=","RB=","Search=Body",LAST);
 web_link("flight_script13.rar",
  "Text=flight_script13.rar",
  "Snapshot=t10.inf",
  LAST);
   i = web_get_int_property( HTTP_INFO_DOWNLOAD_SIZE );
   if (i>0)
  {

     fwrite(lr_eval_string("{FILED}"),i,1,fp);
  }
 lr_think_time( 4 );
   fclose(fp);
 lr_end_transaction("DownLoad", LR_AUTO);

 return 0;
}
希望能够帮助到有需要的人。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下面是一个示例Java代码,用于构造LR(0)项目集规范族并生成识别活前缀的DFA: ``` import java.util.*; public class LR0Parser { private final Map<Integer, Map<String, Integer>> transitions; private final Map<Integer, Map<String, String>> actions; public LR0Parser(Grammar grammar) { // 构造LR(0)项目集规范族 List<Set<Item>> canonicalCollection = buildCanonicalCollection(grammar); // 构造DFA transitions = new HashMap<>(); actions = new HashMap<>(); int state = 0; for (Set<Item> items : canonicalCollection) { Map<String, Integer> transition = new HashMap<>(); Map<String, String> action = new HashMap<>(); for (Item item : items) { if (item.isReduce()) { String production = item.getProduction().toString(); if (item.getProduction().getLeft().equals(grammar.getStart())) { action.put("$", "accept"); } else { for (String lookahead : item.getLookaheads()) { action.put(lookahead, production); } } } else { String symbol = item.getNextSymbol(); int target = getGoto(items, symbol, canonicalCollection); if (grammar.isTerminal(symbol)) { action.put(symbol, "shift " + target); } else { transition.put(symbol, target); } } } transitions.put(state, transition); actions.put(state, action); state++; } } // 构造LR(0)项目集规范族 private List<Set<Item>> buildCanonicalCollection(Grammar grammar) { List<Set<Item>> canonicalCollection = new ArrayList<>(); Set<Item> startItemSet = closure(Collections.singleton(new Item(grammar.getStartProduction(), 0, "$"))); canonicalCollection.add(startItemSet); boolean changed = true; while (changed) { changed = false; for (int i = 0; i < canonicalCollection.size(); i++) { Set<Item> itemSet = canonicalCollection.get(i); Map<String, Set<Item>> transitions = new HashMap<>(); for (Item item : itemSet) { if (!item.isReduce()) { String symbol = item.getNextSymbol(); Set<Item> targetSet = closure(item.moveDot()); transitions.computeIfAbsent(symbol, k -> new HashSet<>()).addAll(targetSet); } } for (Map.Entry<String, Set<Item>> entry : transitions.entrySet()) { Set<Item> targetSet = entry.getValue(); if (!canonicalCollection.contains(targetSet)) { canonicalCollection.add(targetSet); changed = true; } } } } return canonicalCollection; } // 计算一个项目集的闭包 private Set<Item> closure(Set<Item> itemSet) { Set<Item> closure = new HashSet<>(itemSet); boolean changed = true; while (changed) { changed = false; Set<Item> newItems = new HashSet<>(); for (Item item : closure) { if (!item.isReduce()) { String symbol = item.getNextSymbol(); if (!item.getProduction().isNullable() && symbol != null && !newItems.contains(item.moveDot())) { newItems.add(item.moveDot()); } } } if (!newItems.isEmpty()) { closure.addAll(newItems); changed = true; } } return closure; } // 计算一个项目集在给定符号下的转移 private int getGoto(Set<Item> itemSet, String symbol, List<Set<Item>> canonicalCollection) { Set<Item> targetSet = new HashSet<>(); for (Item item : itemSet) { if (!item.isReduce() && item.getNextSymbol().equals(symbol)) { targetSet.add(item.moveDot()); } } return canonicalCollection.indexOf(closure(targetSet)); } // 解析输入串 public boolean parse(String input) { Deque<Integer> stateStack = new ArrayDeque<>(); Deque<String> symbolStack = new ArrayDeque<>(); stateStack.push(0); symbolStack.push("$"); int index = 0; while (true) { int state = stateStack.peek(); String symbol = index < input.length() ? String.valueOf(input.charAt(index)) : "$"; if (!actions.get(state).containsKey(symbol)) { return false; } String action = actions.get(state).get(symbol); if (action.equals("accept")) { return true; } else if (action.startsWith("shift")) { int target = Integer.parseInt(action.substring(6)); stateStack.push(target); symbolStack.push(symbol); index++; } else { Production production = Production.fromString(action); for (int i = 0; i < production.getRight().size(); i++) { stateStack.pop(); symbolStack.pop(); } String nonterminal = production.getLeft(); state = stateStack.peek(); stateStack.push(transitions.get(state).get(nonterminal)); symbolStack.push(nonterminal); } } } } ``` 这段代码LR0Parser类代表了LR(0)分析器,它接受一个文法作为参数,并构造了LR(0)项目集规范族及其对应的DFA。在构造DFA时,对于每个LR(0)项目集,我们使用transitions和actions两个Map来分别存储转移函数和动作表。在解析输入串时,我们使用两个栈来模拟分析栈和符号栈的变化过程。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值